Reputation: 15
i have a website where people can buy/sell services in different cities. I use google maps api v3, autocomplete and searchbox elements, to let them choose a city, store it in the db, and search against the db when they're buying.
Problem is, google searches are localized, so when a user looks for the same city in a different locale they won't find any match in my DB.
My solution would be to map each city to a code (much like yahoo's WOEID) and store that into my db, this way cross locale search would be ok, but i couldn't find anything like it in google maps api reference.
So, is there a way to keep using google maps, do i have to switch to yahoo, or is there another solution to cross locale searches i'm not aware of??
Thank you Dario
Upvotes: 0
Views: 838
Reputation: 22488
If using the Places library, a search returns a PlaceResult
object that has two properties that can help you:
id contains a unique identifier denoting this place. This identifier may not be used to retrieve information about this place, but can be used to consolidate data about this Place, and to verify the identity of a Place across separate searches. As ids can occasionally change, it's recommended that the stored id for a Place be compared with the id returned in later Details requests for the same Place, and updated if necessary.
reference contains a token that can be used to query the Details service in future. This token may differ from the reference used in the request to the Details service. It is recommended that stored references for Places be regularly updated. Although this token uniquely identifies the Place, the converse is not true: a Place may have many valid reference tokens.
Edit:
Note: The
id
andreference
fields are deprecated as of June 24, 2014. They are replaced by the new place ID, a unique identifier that can be used to reference specific places. The Places service in the Google Maps JavaScript API currently returns aplace_id
in all responses, and accepts aplaceId
in the Place Details request. Soon after June 24, 2015, the service will stop returning theid
andreference
fields in responses. Some time later, the service will no longer accept thereference
in requests. We recommend that you update your code to use the new place ID instead ofid
andreference
as soon as possible.
Upvotes: 0