NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: DonRidley on November 23, 2012, 08:14:39 PM

Title: Question about displaying a Google map with multiple markers
Post by: DonRidley on November 23, 2012, 08:14:39 PM
The following code will display a Google map with one marker:

   <html>
     <body>
      <p>Blah</p>
      <div id="map_canvas" style="width:425px; height:550px"></div>
      <p>Blah</p>

      <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
      <script type="text/javascript">

        var map;
        var markers = [];

        initialize();

        function initialize() {
          var myOptions = {
            zoom: 10,
            center: new google.maps.LatLng(33.7309444, -085.8347333),
            mapTypeId: google.maps.MapTypeId.ROADMAP
          }
          map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

          addMarker(new google.maps.LatLng(33.7309444, -085.8347333), "Alien");

        }

        function addMarker(latlng, myTitle) {
          markers.push(new google.maps.Marker({
            position: latlng,
            map: map,
            title: myTitle,
            icon: "http://maps.google.com/mapfiles/marker" + String.fromCharCode(markers.length + 65) + ".png"
          }));   
        }

      </script>
    </body>
  </html>

Thus bit here:
addMarker(new google.maps.LatLng(33.7309444, -085.8347333), "Alien");
places the marker on the map.  This line can be repeated with different coordinates to place multiple markers. 

I would like to loop through a table a get stored coordinates and duplicate the line above as many times as required to display as many markers as I need. 

So, that's my question, how would I loop through a table (I can do that part) and add the lines to the above javascript code?

Thank you!!!

Don
Title: Re: Question about displaying a Google map with multiple markers
Post by: Bruce on November 23, 2012, 10:06:42 PM
Hi Don,

You're a little vague on the context here. Are you embedding in a static page? In a NetWebPage?

Perhaps an example would be appropriate.

cheers
Bruce
Title: Re: Question about displaying a Google map with multiple markers
Post by: DonRidley on November 24, 2012, 03:20:03 AM
NetWebPage.

I attached a screenshot of an example.

I think I have figured out the answer to my question....but please suggest how you would do this.

Thanks,

Don


[attachment deleted by admin]
Title: Re: Question about displaying a Google map with multiple markers
Post by: Bruce on November 25, 2012, 10:20:09 PM
I would do it by adding embed code to the page.

cheers
Bruce
Title: Re: Question about displaying a Google map with multiple markers
Post by: DonRidley on November 26, 2012, 03:28:52 AM
I got it going.

It's easy to make things harder than it has to be...

Thanks,

Don