Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Mapquest:此密钥未授权用于此服务_C#_.net_Openstreetmap_Reverse Geocoding_Mapquest - Fatal编程技术网

C# 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);

我正在尝试使用将我的纬度和经度的地理编码反转为格式化的地址。 我想要一个来自MapQuest的地址,而不是来自其他提供商,如雅虎、谷歌和必应。 这是我的代码:

    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}完成;