NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started 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
-
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
-
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]
-
I would do it by adding embed code to the page.
cheers
Bruce
-
I got it going.
It's easy to make things harder than it has to be...
Thanks,
Don