Skip to content Skip to sidebar Skip to footer

How To Get The Kml Data From A Ggeoxml Object

I load an KML file into a google map object using the following code: map = new GMap2(document.getElementById('map_canvas')); geoXml = new GGeoXml(kml); GEvent.addListener(geoXml,

Solution 1:

you can get the KML from the GGeoXML

have a variable in window

geoXml = newGGeoXml("http://mapgadgets.googlepages.com/cta.kml",
                         function(){
                              geoXml.getKml(
                                function(a){
                                  myKml = a;
                                  alert(myKml);
                                });} );

try it out here: http://code.google.com/apis/ajax/playground/?exp=maps#map_geoxml_kml

just change to one line , alternatively, if you don't want to use the callback of GGeoXML you can call getKml() in some other function after things have finished loading , provided your geoXml doesn't get wiped out

Solution 2:

You can't access it through the API, but the data is available in obfuscated properties inside GGeoXML object. Looking at it in Firebug, I found that information here: geoxml.$q.ia. Look at it yourself to see the properties you need (name, description, etc.).

Post a Comment for "How To Get The Kml Data From A Ggeoxml Object"