5

I am trying to get the list of Maps created by me in Google Maps, and the Maps API says the following:


Retrieving a List of Maps

The Maps Data API provides a feed that lists the maps created by a particular user; this feed is known as a "metafeed". A typical Maps Data API metafeed is a GET request of the following form:

The default feed requests all maps associated with the authenticated user

GET http://maps.google.com/maps/feeds/maps/default/full
Authorization: GoogleLogin auth="authorization_token"

The standard metafeed requests all maps associated with the associated userID

GET http://maps.google.com/maps/feeds/maps/userID/full
Authorization: GoogleLogin auth="authorization_token"

Note that both GET requests require an Authorization HTTP header, passing an AuthSub or GoogleLogin token, depending on which authentication scheme you've implemented. (The GoogleLogin token corresponds to the ClientLogin authentication process.)


I have no idea how to create HTTP request with Authorization HTTP headers. I already have code to get the authorization_token, which is as follows:

# coding: utf-8

import urllib, re, getpass

# http://code.google.com/intl/pt-BR/apis/maps/documentation/mapsdata/developers_guide_protocol.html#ClientLogin

username = 'heltonbiker'
senha = getpass.getpass('Senha do usuário ' + username + ':')

dic = {
        'accountType':      'GOOGLE',
        'Email':            (username + '@gmail.com'),
        'Passwd':           senha,
        'service':          'local',
        'source':           'helton-mapper-1'
        }
url = 'https://www.google.com/accounts/ClientLogin?' + urllib.urlencode(dic)
output = urllib.urlopen(url).read()
authid = output.strip().split('\n')[-1].split('=')[-1]

I also took a look at httplib docs, but didn't understand much (I am not a professional programmer).

Any clue?

1 Answer 1

8

Using urllib2 will make everything easier:

import urllib2

request = urllib2.Request('http://maps.google.com/maps/feeds/maps/default/full')
request.add_header('Authorization', 'GoogleLogin auth=%s' % authorization_token)
urllib2.urlopen(request).read()

BTW, isn't the Google Maps Data API deprecated? http://googlegeodevelopers.blogspot.com/2010/11/maps-data-api-deprecation-announcement.html

Sign up to request clarification or add additional context in comments.

2 Comments

You've hit the spot! I knew there would be some straightforward way to do that. Now for the Maps Data API deprecation, some sites say one thing, some say other... Let's see if that works!
Yes, it works, I get back a XML string with info about all my maps, but I either do not know what do do with the data, and also the API is indeed deprecated. So I will keep using regex to get the MapIDs from this string and automate map download in KML format: 'http://maps.google.com.br/maps/ms?msid=USERID.MAPID&msa=0&output=kml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.