Importing a KML file to Google Maps with api call/request - google-maps

I have geographical data which is represented by a set of points (latitudes and longitudes which form lines), the data is in json. I want to create a Google Map on my website with that data, but the map should also be editable by the user, so he can move the lines, add markers etc.
I could create it using the Google Maps API - with it I can draw polylines, add markers but everything has to be done by my javascript which adds a lot of work.
Google Maps offers a regular user a really nice map editor. To create a map with it the user has to click through the interface or import a KML file.
What I was thinking about, was mixing methods 1. and 2. like this:
a) Export my data to a KML file
b) Import the KML file to a users Google Maps account
c) The user can edit the map with the awesome Google Maps editor
d) Embed the map back on my website with embed code
The problem is with point b) - is it possible to import a KML file to Google Maps using some request/api call?

if you mean on android, yes you can call googlemaps app as an intent from your app and supply a kml file for it to show.
String kmlWebAddress = "http://www.afischer-online.de/sos/AFTrack/tracks/e1/01.24.Soltau2Wietzendorf.kml";
String uri = String.format(Locale.ENGLISH, "geo:0,0?q=%s",kmlWebAddress);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
if you mean online, then you can do so by calling googlemaps and appending "?q=http://www.yourdomain.com/yourfile.kml".
like this:
www.googlemaps.com?q=http://www.afischer-online.de/sos/AFTrack/tracks/e1/01.24.Soltau2Wietzendorf.kml

Related

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?
Found, thanks to all :)
First, make the map public in the Google Map Engine web application:
Click green "Share" button at the right top corner of the map;
Click "Change" access type for anyone;
Select "Anyone with the link" and "Can view" below (shown here);
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!

Getting pins from a saved Google Map into v3 API

I have a saved google map in 'My Places', with over 100+ pins added for locations around the UK. Is there any way I can avoid having to use the embed feature to display this map on a webpage, sort of calling the saved map by ID via the google API?
Essentially what I want to do is get access to google's new visual refresh and be able to control the settings of the map more with API.
The map link is this: https://maps.google.co.uk/maps/ms?msid=207590858966548688521.0004aa52150024d3431b2&msa=0
Can we parse anything here...?
You can overlay the KML output by MyMaps using a KmlLayer in the Google Maps API also:
your MyMaps data displayed on an API based map
Updates in MyMaps will (eventually) be reflected on the map.
Using https://mapsengine.google.com I was able to import the maps data and utilise the pins that way. Not ideal, but still some better functionality.

How to retrieve My Places maps data from Google Maps?

Is it still possible using JavaScript to get My Places data out of Maps? With the move to Fusion Tables and deprecation of the Maps Data API, I can't seem to find information on how to get this data...if it's even available in FT.
The Maps Data API was the only programmatic endpoint to accessing this dataset. However you can still export the data by selecting a map, and then clicking the KML link.
A variety of tools are available for visualizing, importing, and converting KML data in case you want to import it elsewhere.

Is there an API to add markers to user created public/unlisted maps in Google Maps?

I created a map with a few markers and saved it at http://maps.google.com/.
Is there a way to edit the map with an API, like inserting and deleting markers from it?
Or, is there a way to add markers to the default preview at http://maps.google.com/ without saving it? (Possibly through adding parameters to the URL).
The problem raises due to contract between Google Maps and Israel's map provider, which doesn't allow Google to show Israel's streets through an API, and only through the interactive map at http://maps.google.com/.
Thanks ahead!
if you are using Google Maps API, you can save markers in an database, so, you can inser, delete, update markers. When you load you web app where you are using the API you have to create an XML file with coordenates and info, then use a javascript to read XML file

Google Maps with custom GEORss file

Where would I need to host an xml file in order to use it in Google maps for GEORss ??
From google api docs...
var georssLayer = new google.maps.KmlLayer('http://api.flickr.com/services/feeds/geo/?g=322338#N20&lang=en-us&format=feed-georss');
georssLayer.setMap(map);
this seems to do a great job of creating the info popouts and everything...
It would seem i cannot have one locally...
So i guess i need an aspx or ashx to push the xml...but does it have to be web accessible?
Thx
Yes, it needs to be web accessible because Google converts the GeoRSS to KML on the server side:
"The Google Maps API supports the KML and GeoRSS data formats for displaying geographic information. These data formats are displayed on a map using a KmlLayer object, whose constructor takes the URL of a publicly accessible KML or GeoRSS file.
The Maps API converts the provided geographic XML data into a KML representation which is displayed on the map using a V3 tile overlay."
http://code.google.com/apis/maps/documentation/javascript/overlays.html#KMLLayers
If you are hosting a static XML file, you might use Amazon Web Service's Simple Storage Service: http://aws.amazon.com/s3/