C# Mapquest:此密钥未授权用于此服务
我正在尝试使用将我的纬度和经度的地理编码反转为格式化的地址。 我想要一个来自MapQuest的地址,而不是来自其他提供商,如雅虎、谷歌和必应。 这是我的代码:C# Mapquest:此密钥未授权用于此服务,c#,.net,openstreetmap,reverse-geocoding,mapquest,C#,.net,Openstreetmap,Reverse Geocoding,Mapquest,我正在尝试使用将我的纬度和经度的地理编码反转为格式化的地址。 我想要一个来自MapQuest的地址,而不是来自其他提供商,如雅虎、谷歌和必应。 这是我的代码: try { IGeocoder geocoder = new MapQuestGeocoder("Fmjtd%7Cluu82q6***********"); var addresses = geocoder.ReverseGeocode(latitude, longitude);
try
{
IGeocoder geocoder = new MapQuestGeocoder("Fmjtd%7Cluu82q6***********");
var addresses = geocoder.ReverseGeocode(latitude, longitude);
return ("Formatted address : " + addresses.First().FormattedAddress);
}
catch (Exception exception)
{
return exception.Message;
}
此代码捕获异常,并警告此错误“此密钥未被授权用于此服务”
我知道当我尝试点击Geocoder的企业API时会发生这个错误,即*******************
对于免费和开源的使用,我应该点击以下API:
我该怎么做?在构造函数本身中是否有传递POST URL的选项?或者其他方式?浏览geocoder.net的开源代码,看起来您只需要将geocoder对象的“UseOSM”属性设置为true:
geocoder.UseOSM = true;
这很简单。您不需要更改URL。只需添加UseOSM=true,如下所示:
try
{
IGeocoder geocoder = new MapQuestGeocoder("Fmjtd%7Cluu82q6***********"){UseOSM = true};
var addresses = geocoder.ReverseGeocode(latitude, longitude);
return ("Formatted address : " + addresses.First().FormattedAddress);
}
catch (Exception exception)
{
return exception.Message;
}
+谢谢你。你是对的。!!也可以通过IGeocoder geocoder=new MAPQUESTGOCODER(“Fmjtd%7CLOU82Q6********”){UseOSM=true}完成;