Skip to content

Instantly share code, notes, and snippets.

@lirenyeo
Created September 17, 2019 11:58
Show Gist options
  • Save lirenyeo/f9db9bf5dec7ef8fadd1124f02151709 to your computer and use it in GitHub Desktop.
Save lirenyeo/f9db9bf5dec7ef8fadd1124f02151709 to your computer and use it in GitHub Desktop.

Google Places APIs

/maps/api/place/autocomplete

  • Takes input string and return multiple matching addresses with place_id
  • Can use lat,lng location + radius to create bias result
  • result is different than /textsearch
  • ex: no result for ไลฟ์ สุทธิสาร

/maps/api/place/queryautocomplete

  • Can process request like 'cafe near me'

/maps/api/place/textsearch

  • Takes querystring and return matching addresses with placeid, lat and lng
  • result is different than /autocomplete
  • ex: return one result for ไลฟ์ สุทธิสาร

/maps/api/place/details

  • Takes placeid and return address and coordinate

/maps/api/place/findplacefromtext

  • Basically /autocomplete with single result
  • No result for ไลฟ์ สุทธิสาร, while /textsearch has result

/maps/api/place/nearbysearch

  • Takes location (lat,lng) and radius in meter and return nearby business establisment with address, placeid, rating, opening hours, etc
  • Only return business establishments
  • cost 10x request

/maps/api/place/geocode

  • Takes lng,lat and return multiple addresses and place_ids (from most to least specific of that exact same spot)
  • for example:
    • Result 1: 699, Jalan Damansara, TTDI, 60000 KL
    • Result 2: Jalan Damansara, TTDI, 60000 KL
    • Result 3: TTDI, 60000 KL
    • Result 4: KL

Map drag and pin to get address

  1. Drag map to get coordinate
  2. Call /geocode to get address
  3. Call /autocomplete with the address
  4. Call /textsearch if no result
  5. Optional /nearbysearch if needed

Autocomplete

  1. /autocomplete with input text
  2. /textsearch if no result
  3. To get coordinate, call /details with placeid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment