简体   繁体   中英

Google geocoding API - Search on specific fields

I know Google provides various component types to search upon, apart from the list shown below.

administrative_area_level_1
administrative_area_level_2
locality
sublocality
postalcode

suppose user searches for something. Is it possible to restrict the user search for only above mentioned parameters instead of all.

How can I make my URL then.

Country I know I can restrict. this is the URL I'm forming and hitting,

But I want to restrict the search ( uttam+nagar ) on above parameters only.

https://maps.googleapis.com/maps/api/geocode/json?key=AIzaSyDnLJxpRbJpS2NEbiOf-FQ-K-YmQZ8V-yw&components=country%3AIN&address=uttam+nagar

If I've understand your needs, I think you can use Component filtering

You can also set the Geocoding Service to return address results restricted to a specific area. Specify the restriction by using the componentRestrictions parameter. A filter consists of one or more of: route, locality, administrativeArea, postalCode or country. Only results matching all the filters will be returned. Filter values support the same methods of spelling correction and partial matching as other geocoding requests.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM