mardi 26 mai 2015

Any way I can load KML data from Google maps (again) via JS API?

I’ve been working on a little ember app for a while which loaded articles from a local newspapers API and presented it in a nice layout. As these articles are all about travel destinations, the navigation is based upon a big map with markers in the background of the page. Originally I started out with a leaflet map. Adding a marker for each article was no problem, as I knew their coordinates as they were saved with each article and accessable through the API.

It got more complicated when I realized that some authors embedded small Goolge maps into their copy with markers for nice sites, bars, etc. As I didn’t want to have a Google map displayed over a leaflet map, I was searching for way to get the marker data from the Google maps and use it on my Leaflet one. The solution I ended up working with was pretty crazy but did what I was hoping for: I realized that an HTTP request to a Google map’s embed url with the request parameter “output” set to “kml” got me an KML/XML file with all the data of the KML layer used with the map. To circumvent issues with cross-domain requests I requested the KML data indirectly through Yahoo’s YQL service which kindly converted the data to JSON as well.

Everything was fine. Until it wasn’t. Since implementing the recent changes to the API (especially regarding KML stuff), my requests return KMZ (zipped KML) data. Of course neither YQL conversion nor my Ember app can deal with the now binary data.

It doesn’t seem there is any way to get my hands on the uncompressed data again. Is there at least a way to make my main map–which is now a Google map, too–load the kml layer from another map identified by an embed url? Any hint is welcome and really appreciated. Thanks!




Aucun commentaire:

Enregistrer un commentaire