谷歌地图V3的地理编码服务器端 [英] Google Maps v3 geocoding server-side
本文介绍了谷歌地图V3的地理编码服务器端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用ASP.NET MVC 3和谷歌地图V3。我想这样做地理编码的一个动作。这是传递一个有效的地址,谷歌和获取经纬度回来。在地理编码所有在线样本,我已经看到已经处理了客户端地理编码。你会如何使用C#这样做的一个动作?
I'm using ASP.NET MVC 3 and Google Maps v3. I'd like to do geocoding in an action. That is passing a valid address to Google and getting the latitude and longitude back. All online samples on geocoding that I've seen have dealt with client-side geocoding. How would you do this in an action using C#?
推荐答案
我不知道如果我理解正确,但是这是我做的方式(如果你有兴趣)
I am not sure if I understand you correctly but this is the way I do it (if you are interested)
void GoogleGeoCode(string address)
{
string url = "http://maps.googleapis.com/maps/api/geocode/json?sensor=true&address=";
dynamic googleResults = new Uri(url + address).GetDynamicJsonObject();
foreach (var result in googleResults.results)
{
Console.WriteLine("[" + result.geometry.location.lat + "," + result.geometry.location.lng + "] " + result.formatted_address);
}
}
这篇关于谷歌地图V3的地理编码服务器端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文