Closed GoogleCodeExporter closed 8 years ago
removing var mgr = new MarkerManager(map); eliminates the runtime error
Original comment by rad131...@gmail.com
on 20 Apr 2009 at 4:47
The following code executes sucessfully:
function initialize() {
if (document.getElementById("map_canvas") && GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.disableDragging();
map.setMapType(G_HYBRID_MAP);
var address = "Syracuse NY, USA";
var geocoder = new GClientGeocoder();
map.setCenter(new GLatLng(37.4419, -122.1419), 13)
var mkrMgr = new MarkerManager(map, { trackMarkers: true });
GEvent.addListener(map, "click", function(overlay, latlng) {
if (DEBUG == 1) alert("You clicked the map.");
mkrMgr.addMarkers(new GMarker(latlng), 16);
}
);
}
}
The following code fails:
function initialize() {
if (document.getElementById("map_canvas") && GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.disableDragging();
map.setMapType(G_HYBRID_MAP);
var address = "Syracuse NY, USA";
var geocoder = new GClientGeocoder();
geocoder.getLatLng(address, function(point) {if (!point) alert(address
+ " not found"); else map.setCenter(point, 6);});
var mkrMgr = new MarkerManager(map, { trackMarkers: true });
GEvent.addListener(map, "click", function(overlay, latlng) {
if (DEBUG == 1) alert("You clicked the map.");
mkrMgr.addMarkers(new GMarker(latlng), 16);
}
);
}
}
The only conclusion that I can come to is that the MarkerManager is envoked
before
map.setCenter, causing the error.
This dependency should be listed somewhere in the documentation.
Original comment by rad131...@gmail.com
on 20 Apr 2009 at 6:48
The core Maps API documentation does say that setCenter must always be called
after
GMap2; it is an error to do otherwise.
http://code.google.com/apis/maps/documentation/reference.html#GMap2
http://code.google.com/apis/maps/documentation/reference.html#GMap2.setCenter
Original comment by pamela.fox
on 20 Apr 2009 at 8:26
Not all of your documentation is correct:
http://code.google.com/apis/maps/documentation/overlays.html#Marker_Manager
Original comment by rad131...@gmail.com
on 21 Apr 2009 at 11:35
Good point, that will be fixed in next few days.
Original comment by pamela.fox
on 23 Apr 2009 at 4:30
Original issue reported on code.google.com by
rad131...@gmail.com
on 20 Apr 2009 at 4:45