简体   繁体   中英

Read placemark information from Google Map in Javascript

I am trying to get/extract the information of a placemarker ie title and coordinates from a Google map which has been loaded from a KML file. The KML file is hosted publicly by Google Maps and is loaded using the V3 API, example:

var ctaLayer = new google.maps.KmlLayer({
            url: 'https://mapsengine.google.com/map/kml?mid=' + kmlId
        });

ctaLayer.setMap(myMap);

How can I do this all on the client-side using javascript/jQuery?

My first thought is to screen scrape but I can't seem to find the placemarker...

You need to parse the KML to get the information about the placemark. The google.maps.KmlLayer doesn't give you access to that. If the KML is not on your server, you will have to access it through a proxy.

You could load the kml using a third party parser (like geoxml3 or geoxml-v3 , there are many), then the internals would be available, but, depending on the complexity of the KML, you might run into performance issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM