Google Places API - find an address using the city

前端 未结 3 736
说谎
说谎 2020-12-17 00:10

I am planning to use Google Places API in order to create an address autocomplete in my web site. My question is about whether my requirements are possible using Google Plac

3条回答
  •  不思量自难忘°
    2020-12-17 01:17

    Google Places will help your user autocomplete their address as Sean Mickey describes:

    1. They start typing their street address in a single field
    2. Google gives them a list of possible matching addresses
    3. They pick one, and you get back a response like this

    The id in that response is going to be for their street address, not for the city. So it's not going to be useful the way you want. If you want to match on city, you need to store the name of the city (if you want you can create your own id table).

    Think about how you want to implement location search in your database:

    • Search by city (misses people who live just outside the city limits)
    • Search by distance (finds everyone within a certain radius)

    If you choose to search by distance, you should also be storing the Latitude and Longitude that Google Places gives you back when the user enters their address. You also need to read up on how to do spatial search in your database (especially geodist).

提交回复
热议问题