Google Maps API Parameters

Question

I'm sure this is an obvious mistake, but does anyone know why this code isn't working? Am I using the python requests library incorrectly?

import requests

header =  {'Content-Type ': 'application/json'}
body = {
  "api_key": REDACTED,
  "size": "200x200",
  }

response = requests.get("https://maps.googleapis.com/maps/api/staticmap", headers = header, json = body)
data = response.content

print data

Ultimately, I'm trying to create an URL to a Google Map (with additional parameters I will set, such as lats/longs and markers).


Show source
| url   | python   | python-requests   | google-maps   2017-01-06 23:01 1 Answers

Answers to Google Maps API Parameters ( 1 )

  1. 2017-01-07 23:01

    Figured it out - was setting my parameters incorrectly.

    import requests
    params = {'Content-Type ': 'application/json',  "api_key": REDACTED, "size": "200x200"}
    
    response = requests.get("https://maps.googleapis.com/maps/api/staticmap", params = params)
    data = response.url
    print data
    

Leave a reply to - Google Maps API Parameters

◀ Go back