当我尝试获取城市列表并动态填充谷歌地图网页时,有没有一种方法可以输入城市名称并获取该位置的纬度和经度。
我有下面代码的想法,但我没有纬度或经度点。
foreach (City city in cities)
{
markerString.AppendLine(" var point" + i + " = new GLatLng(" + city .Location.Latitude + "," + city .Location.Longitude + ");");
markerString.AppendLine(" var marker" + i + " = new GMarker(point" + i + ");");
markerString.AppendLine(" marker" + i + ".value = " + i + ";");
}
最佳答案
是的。这称为 geocoding 。
Google 的 javascript 地理编码 API:http://code.google.com/apis/maps/documentation/services.html#Geocoding
HTTP API:http://code.google.com/apis/maps/documentation/geocoding/index.html
用于地理编码的 C# 库:http://code.google.com/p/geocoding-net/ (使用 Google、Yahoo 或 Microsoft)。
关于c# - 创建谷歌地图网站 - 将城市映射到纬度和经度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1887899/