Note that there are some explanatory texts on larger screens.

plurals
  1. POImplementing a Basic Google Place Add with Python
    primarykey
    data
    text
    <p>I want to allow users to add places to Google Maps using my app. This tutorial shows how to implement a Place Search <a href="https://developers.google.com/academy/apis/maps/places/basic-place-search" rel="nofollow">https://developers.google.com/academy/apis/maps/places/basic-place-search</a> I understand the code but Place Search and Place Add are different. In Place Add we have to use a POST URL and POST body <a href="https://developers.google.com/places/documentation/?hl=fr#adding_a_place" rel="nofollow">https://developers.google.com/places/documentation/?hl=fr#adding_a_place</a>. I don't know how to insert POST body in my code. I want to use this code but to adapt it to Place Add:</p> <pre><code>import urllib2 import json AUTH_KEY = 'Your API Key' LOCATION = '37.787930,-122.4074990' RADIUS = 5000 url = ('https://maps.googleapis.com/maps/api/place/search/json?location=%s' '&amp;radius=%s&amp;sensor=false&amp;key=%s') % (LOCATION, RADIUS, AUTH_KEY) response = urllib2.urlopen(url) json_raw = response.read() json_data = json.loads(json_raw) if json_data[‘status’] == ‘OK’: for place in json_data['results']: print ‘%s: %s\n’ % (place['name'], place['reference'])' </code></pre> <p><strong>EDIT</strong></p> <p>Thanks for your help @codegeek I finally find the solution based on this library <a href="https://github.com/slimkrazy/python-google-places" rel="nofollow">https://github.com/slimkrazy/python-google-places</a></p> <pre><code>url = 'https://maps.googleapis.com/maps/api/place/add/json?sensor=false&amp;key=%s' % AUTH_KEY data = { "location": { "lat": 37.787930, "lng": -122.4074990 }, "accuracy": 50, "name": "Google Shoes!", "types": ["shoe_store"] } request = urllib2.Request(url, data=json.dumps(data)) response = urllib2.urlopen(request) add_response = json.load(response) if add_response['status'] != 'OK': # there is some error </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload