I'm using GGeoXML and a KML file to create my map. Everything works
perfectly, with one annoying exception. The GMap2 documentation says
that you have to call GMap2.setCenter() before you make any other
calls to the map, and sure enough, if I don't call setCenter(), then
my map won't even display. Easy enough: call setCenter(). The problem
is that my map contents are variable, so I don't generally have a good
idea of WHERE to set the center. So I call setCenter(new GLatLng(0,
0)). This causes me to see a world map centered on (0, 0) for a split
second, and then my KML file loads, and the map refreshes to show what
I really want to see. I don't see any other Google Maps on the web
behaving this way, so surely I'm just making a newbie mistake. Anyone
have any advice? Here's a link:
http://gayscenehotels.clubtroll.com/viewcities.php?countryID=8,
then you have to click on 'Amsterdam'. Here's my code:
var map;
var geoxml;
function load() {
if (GBrowserIsCompatible()) {
var url_end = "?nocache=" + (new Date()).valueOf();
var myKML = "http://gayscenehotels.clubtroll.com/kml/city_" +
getCookie('cityID') + '.xml' + url_end;
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(0, 0));
// Add controls
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
geoxml = new GGeoXml(myKML);
GEvent.addListener(geoxml, "load", handleGeoXMLLoad);
map.addOverlay(geoxml);
}
}
function handleGeoXMLLoad() {
geoxml.gotoDefaultViewport(map);
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---