My app has a search for cities, but when the user enters the full address, he gets placeId
that is more specific than a city -- for an address, or a business. I want the placeId
for the city to store in my database.
I'm using Geocomplete http://ubilabs.github.io/geocomplete/
$('input[name="address"]').geocomplete().bind('geocode:result', function(event, result){
console.log(result.place_id)
});
I need to get place_id
city from place_id
address and check validity in PHP.
You can avoid results that represent full addresses by using types
to (regions)
or (cities)
, see details here .
Whether to use one or the other will depend on which countries you want results from, because sometimes cities can be administrative_area1
(eg Tokyo), see the note in the Place Autocomplete Address Form example.
根据geocomplete的文档,将触发事件geocode:result
并显示此处描述的结果 ,您需要查看此处描述的address_components
并使用administrative_area
字段之一
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.