How to use google maps API with multiple markers on the same map
- by Maen
So, i have the following script to use the google maps API, its all fine, but i need to create a map that has more than one Marker (the balloon shaped icon pointing to something) and i need each of those markers to point on a different area of the map (i.e. different coordinates), how can i do it?
<script type="text/javascript">
function load() {
var map = new GMap2(document.getElementById("map"));
var marker = new GMarker(new GLatLng(<%=coordinates%>));
var html="<img src='simplemap_logo.jpg' width='20' height='20'/> " +
"<%=maptitle%><br/>" +
"<%=text%>";
map.setCenter(new GLatLng(<%=coordinates%>), <%=zoom%>)
map.setMapType(G_HYBRID_MAP);
map.addOverlay(marker);
map.addControl(new GLargeMapControl());
map.addControl(new GScaleControl());
map.addControl(new GMapTypeControl());
marker.openInfoWindowHtml(html);
}
//]]>
</script>
One more question, if i pass the Script text as a variable, lets say something like:
<script type="text/javascript">
<%=ScriptText%>
</script>
and my <%=ScriptText% will be a string which i will build and assign its value to a Friend or Public variable called ScriptText, will it still run and work properly? (i am doing this to make my script dynamic and different based on how i build it as a STRING, due to my illiteracy in javascripting ;P)