I am building a web application using the Google Maps API v3. I want to display some places on the map that are stored in the "My places" section of a Google user account on Google Maps.
I know that the Google Maps API supports KML, and I can download KML from Google Maps My Places. But I want to do this programmatically.
Example:
A user comes to my site, logs in using their Google credentials, and they can see a list of their saved places. After clicking on one of them, this place will appear on the map, which is in my web application.
Please suggest how I do this.
I found this Location Access in My Places specific account through the Google Maps API and tried this as follows:
import urllib2, urllib, re, getpass username = 'abhishekworld' senha = getpass.getpass('password' + username + ':') dic = { 'accountType': 'GOOGLE', 'Email': (username + '@gmail.com'), 'Passwd': senha, 'service': 'local', 'source': 'themappers' } url = 'https://www.google.com/accounts/ClientLogin?' + urllib.urlencode(dic) print url output = urllib2.urlopen(url).read() authid = output.strip().split('\n')[-1].split('=')[-1] request = urllib2.Request('http://maps.google.com/maps/feeds/maps/default/full?access_token='+authid) request.add_header('Authorization', 'GoogleLogin auth=%s' % authid) source = urllib2.urlopen(request).read() open('feed.xml','w').write(source) for link in re.findall('<link rel=.alternate. type=.text/html. href=((.)[^\1]*?)>', source): s = link[0] if 'msa=0' in s: msid = s.split(";")[-1] print "https://maps.google.com/maps/ms?authuser=0&vps=2&ie=UTF8&msa=0&output=kml&"+msid
Although this works great, after several logins, Google sends you an email with the message “suspicious activity”, so I need a clean solution. Please let me know if there is any clean way to do this.
source share