如何使用C#查找经纬度

问题描述:

我在C#中有一个WCF服务.

I have a WCF service in C#.

在服务呼叫中,客户端发送城市名称.我想将城市名称转换为纬度和经度,并存储在人口统计"下的数据库"中.

In the Service call client sends a city name. I want to convert the city name to latitudes and longitudes and store in Database under demographics.

我正计划使用Google API来实现上述功能.

I am planning to use Google API to implement above functionality.

我已经从Google获得了API密钥,并且类型为服务帐户".

I have obtained an API key from Google and its of type 'Service account'.

如何使用哪些API获取纬度和经度?

How can I obtain the latitude and longitude using which APIs?

我需要安装某些SDK还是任何REST服务都可以?

Do I need to install some SDK or any REST Service will do?

如果您想使用Google Maps API来查看其REST API,则无需安装Google Maps API,只需发送以下请求即可

If you want to use the Google Maps API have a look at their REST API, you don't need to install a Google Maps API just send a Request like

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

,您将获得一个响应XML.

and you will get a response XML.

对于响应JSON:

https://maps.googleapis.com/maps/api/geocode/json?address=1600+Estância+Sergipe,&key=**YOUR_API_KEY**

有关更多信息,请参阅

https://developers.google.com/maps/documentation/geocoding /index#GeocodingRequests