开发者

What is a good API to use to determine the address of a place based on its name?

开发者 https://www.devze.com 2023-02-21 23:48 出处:网络
I need to get the specific address (or lat/long coordinates) of a place based on that place\'s name. Specifically, I need to determine the location of supermarkets in a given area so that I can use t

I need to get the specific address (or lat/long coordinates) of a place based on that place's name.

Specifically, I need to determine the location of supermarkets in a given area so that I can use those locations as 'markers' in my implementation of google maps static maps api.

Using the following, I can if you input a specific location in the area that currently says "INSERT_LOCATION_HERE", then you will get a google map of the specified area with markers at the locations.:

http://maps.google.com/maps/api/staticmap?center=Ithaca,%20NY&size=512x512&maptype=roadmap&markers=color:blue|label:S|INSERT_LOCATION_HERE&sensor=false

For example (the marker indicates the local Wegmans store based on its address:

 http://maps.google.com/maps/api/staticmap?center=Ithaca,%20NY&size=512x512&maptype=roadmap&markers=color:blue|label:S|500%20So.%20Meadow%20Street&sensor=开发者_开发技巧false

If anyone knows how to do this without using google maps places api, that would be extremely helpful!


If you want to get the name as a string intead of an image, you can do it with a little help for Google. That'll match nicely with the static map that you're using.

Let's say you want to search for "Den Haag"...

Construct a URL like this, and parse the result:

  • http://maps.google.com/maps/geo?q=den%20haag

You can also specify the output format:

  • http://maps.google.com/maps/geo?q=den%20haag&output=xml
  • http://maps.google.com/maps/geo?q=den%20haag&output=csv
  • http://maps.google.com/maps/geo?q=den%20haag&output=json

You can also provide coordinates instead of a name, and get a full name+coordinates in return:

  • http://maps.google.com/maps/geo?q=52.0467315,4.3796239&output=json

For some reason the links don't work when you click them from this page. I guess google doesn't accept a referrer in the request, so just copy and paste the links... That works.

0

精彩评论

暂无评论...
验证码 换一张
取 消