Does Google Maps API offer a way to search for locations by name?

落爺英雄遲暮 提交于 2019-12-04 08:20:38

问题


When one visits http://maps.google.com, they are able to type queries into the search field and receive results based on locations or places, and not hard search results, as they would in a normal Google Search query. They're a unique style of result (names of places, locations) suited to the Maps interface for obvious reasons.

I've been digging through both the Maps and standard Google Search API for a couple hours now, and have done multiple searches on this question, and I can't seem to find the answer.

They obviously have the Local Search, but that's been deprecated, and it only yields results if you provide an initial lat/long. I want to be able to find places or locations with no initial lat/long.

Essentially what I want to do is allow a user to type in an address, name of a place or name of a city or state or a zip code, or essentially any other kind of location that is allowable on Maps, and geocode it. I feel stupid because this seems like it has to be there, but nothing I've seen in the API seems to do this.

I don't need the AJAX suggested results, necessarily. Just a way for a user to type in a nice name and geocode from it, though results as a user types would be ideal.

What am I missing here?


回答1:


What you are looking is Geocoding API from google maps.

Find Documentation here

UPDATE 5/12/2011

Google just opened up public access to their Places API. This is more to the heart of the original question request:

http://code.google.com/apis/maps/documentation/places/autocomplete.html




回答2:


I think you're looking for the google.maps.Geocoder class:

A service for converting between an address and a LatLng.



来源:https://stackoverflow.com/questions/5926369/does-google-maps-api-offer-a-way-to-search-for-locations-by-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!