> Any Ideas?

Try this:

function initialize() {
        if (GBrowserIsCompatible()) {
                var mapdiv = document.getElementById("gmap");
                var map = new GMap2(mapdiv);

                map.setCenter(new GLatLng(0, 0), 0);
                map.setUI(new GMapUIOptions(new GSize(mapdiv.clientWidth,
mapdiv.clientHeight)));

                var gxml = new GGeoXml("file.kml");
                GEvent.addListener(gxml, "load", function {
                        if (gxml.hasLoaded()) {
                                map.setCenter(gxml.getDefaultCenter(), 
map.getBoundsZoomLevel
(gxml.getDefaultBounds()));
                        }
                });
                map.addOverlay(gxml);
        }
}

initialize();

Works fine for me, but...
I don't like the "map.setCenter(new GLatLng(0, 0), 0);" statement. How
else would you do that? It is an "error" to call any GMap2 functions
before a setCenter operation! So no addOverlay operation possible
before that! And thus the event will not be fired. But you need the
event to get the center... bit of a chicken - egg problem here...
The problem is (besides the dirty code), that the UI "return to the
last result" function uses this center and zoom level instead of the
kml infos.
btw. - setting the kml center twice inside the event wont help... any
suggestions?

The Atom
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to