Google maps get latitude and longitude having city name?

后端 未结 3 578
你的背包
你的背包 2021-01-30 04:33

I want to get latitude and longitude of a city by providing the API with the city name. It should work for most cities regardless how the user inputs the city.

For examp

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-30 05:07

    You can use Google's geocoding service, e.g.,

    http://maps.googleapis.com/maps/api/geocode/xml?address=Miami+FL&sensor=false

    That gives you back georeferenced data in a variety of formats (JSON, XML, etc). In any event, the location is definitely in the returned data block.

    The API docs are at:

    https://developers.google.com/maps/documentation/geocoding/

提交回复
热议问题