Search code examples
google-mapscurlkmlgoogle-maps-engine

Google Maps Engine: export kml curl


There is a map created in the new Google maps engine editor. Now the map needs to be exported as KML using Curl. Previous version of the maps editor (now called "MyPlaces" or "My Maps classical version") allows export the map by ID using this template for URL:

https://maps.google.com/maps/ms?oe=UTF8&hl=ru&msa=0&msid=${ID}&output=kml

New map ID neither looks like the old one (zv44oKISEgzs.kzcf044WEB9o vs 107197571518206937258.000453b7c5de92024cf27 respectively), nor it does fit the export API. Google responds with 200 OK but with empty response body.

Is there any similar API call in the new Maps Engine to get the map exported as KML with just a line of shell?


Solution

  • Found, thanks to all :)

    First, make the map public in the Google Map Engine web application:

    1. Click green "Share" button at the right top corner of the map;
    2. Click "Change" access type for anyone;
    3. Select "Anyone with the link" and "Can view" below (shown here);
    4. Click "Save".

    Then you can easily download this map as KML using this URL template:

    https://mapsengine.google.com/map/kml?mid=${ID}
    

    UPDATE: Google started sending the KML file as KMZ. Don't panic, KMZ is just a zip archive of single KML file. To fix the algorithm just add funzip tool (apt-get install unzip) in the end of shell pipe like this:

    curl -s 'https://mapsengine.google.com/map/kml?mid=${ID}' | funzip
    

    Or use an unzip library native to your language. Keep having fun with Google API updates!