Hey. I’mm trying to put two points on a single map with same div id..
but it doesn’t work..
code:
for 1st,
var map = new GMap2(document.getElementById("map-canvas"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(<?=$lat;?>,<?=$lng;?>), 6);
var point = new GLatLng(<?=$lat;?>,<?=$lng;?>);
var marker = createMarker(point,'Welcome:<b></b><br>Second Info Window with an image<br><img src="http://localhost/gps/user_photo/" width=80 height=80>')
map.addOverlay(marker);
function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
for 2nd,
var map = new GMap2(document.getElementById("map-canvas"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(<?=$mylat;?>,<?=$mylng;?>), 6);
var point1 = new GLatLng(<?=$mylat;?>,<?=$mylng;?>);
var marker = createMarker1(point1,'Welcome:<b></b><br>Second Info Window with an image<br><img src="http://localhost/gps/user_photo/" width=80 height=80>')
map.addOverlay(marker);
function createMarker1(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
why two points not shown in one map?????
and it will seen in two different maps…
This is one way of doing it just to get it working for you, but essentially the js points and markers should be arrays which you loop through – ditto probably the $mylat and $mylong vars in PHP.