google maps - javascript problem -
i have problem google maps v3 code part of example google. want add listener each marker, set marker array. not working :( can me?
function initialize() { if (gbrowseriscompatible()) { var map = new gmap2(document.getelementbyid("map_canvas")); map.setcenter(new glatlng(37.4419, -122.1419), 13); // add 10 markers map @ random locations var bounds = map.getbounds(); var southwest = bounds.getsouthwest(); var northeast = bounds.getnortheast(); var lngspan = northeast.lng() - southwest.lng(); var latspan = northeast.lat() - southwest.lat(); var marker = new array(10); (var = 0; < 10; i++) { var latlng = new glatlng(southwest.lat() + latspan * math.random(), southwest.lng() + lngspan * math.random()); marker[i] = new gmarker(latlng,{ draggable: true }); gevent.addlistener(marker[i] , "dragstart", function() { map.closeinfowindow(); }); gevent.addlistener(marker[i] , "dragend", function() { marker[i].openinfowindowhtml("text" + i); }); map.addoverlay(marker[i] ); } } }
google maps v2 api deprecated, should use v3. see working example using new api: google maps js api v3 - simple multiple marker example
Comments
Post a Comment