如果邮政编码相同且地址不同,Bingmap api会提供相同的坐标

时间:2017-12-11 13:53:25

标签: c# rest bing-maps

我正面临以下问题。我有2个地址和相同的邮政编码。我使用BingMap API。重点是提供相同的坐标。

地址1:

http://dev.virtualearth.net/REST/v1/Locations?addressLine=chandranagar, Near PPCC ground&postalCode=380007&maxResults=1?key=yourBingMapsKey

地址2:

http://dev.virtualearth.net/REST/v1/Locations?addressLine=C603 satva flats near shantivan chandranagar&postalCode=380007&maxResults=1?key=yourBingMapsKey

上述两个地址都提供相同的结果。

代码:

string bingMapsUri = "http://dev.virtualearth.net/REST/v1/Locations?" + mapAddress + "&key=" + bingMapKey;
using (var client = new WebClient())
{                                         
    string response = client.DownloadString(bingMapsUri);
    response = response.Replace("__type", "mytype");
    LocationQueryResponse root = new LocationQueryResponse();
    MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(response));
    DataContractJsonSerializer ser = new DataContractJsonSerializer(root.GetType());
    root = ser.ReadObject(ms) as LocationQueryResponse;
    ms.Close();
}

1 个答案:

答案 0 :(得分:0)

原因是您的addressLine值不是地址行,而是地理编码器不支持的兴趣点查询。您正在寻找的是一个免费的表单兴趣点/商家列表API。我不知道任何此类API在印度有良好的覆盖率。如果您决定对地址使用Bing Maps地理编码服务,请务必使用最佳实践:https://msdn.microsoft.com/en-us/library/dn894107.aspx如果使用.NET,请查看已实施所有最佳实践的Bing Maps REST .NET工具包。您并且易于使用:https://github.com/Microsoft/BingMapsRESTToolkit