开发者

Get Latitude and Longitude of a location [duplicate]

This question already has answers here: Closed 10 years ago.

Possible Duplicate:

how i can get latitude , longitude of a location programmatically or using a api

I am using > http://www.weather.gov/forecasts/xml/SOAP_server/ndfdXML.htm. to get the weather detials of location. Here I need to pass latitude and longitude to the webmethod. I have location name but not the latitude & lon开发者_高级运维gitude values.So I want to get these 2 values of a location. Is there any way to get it.


Since you tagged the question with Google I presume you would want to use the Google Geocoding API service? The documenation there pretty much explains how to use it - you pass the address as a query-string parameter to the service (via simple REST like URL) and you can get back either XML or JSON. An example of an XML query:

http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false

As part of the XML response you will see the lat/long:

<location>
  <lat>
     37.4213068
  </lat>
  <lng>
     -122.0852900
   </lng>
</location>

Just remember to set the sensor parameter to either true or false as this is required.

Note the v3 API doesn't require an API key but does have some usage limitations you should be aware of, including:

  • a query limit of 2,500 geolocation requests per day.
  • the Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜