我使用的是Bing Maps、SOAP、c#和.net。我想实现GeocodeAddress(),但类型或命名空间名称'Confidence'在命名空间中不存在:
private String GeocodeAddress(string address)
{
string results = "";
string key = "insert your Bing Maps key here";
GeocodeRequest geocodeRequest = new GeocodeRequest();
// Set the credentials using a valid Bing Maps key
geocodeRequest.Credentials = new DevExpress.Map.BingServices.Credentials();
geocodeRequest.Credentials.ApplicationId = key;
// Set the full address query
geocodeRequest.Query = address;
// Set the options to only return high confidence results
ConfidenceFilter[] filters = new ConfidenceFilter[1];
filters[0] = new ConfidenceFilter();
filters[0].MinimumConfidence = GeocodeService.Confidence.High;
// Add the filters to the options
GeocodeOptions geocodeOptions = new GeocodeOptions();
geocodeOptions.Filters = filters;
geocodeRequest.Options = geocodeOptions;
// Make the geocode request
GeocodeServiceClient geocodeService = new GeocodeServiceClient();
GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest);
if (geocodeResponse.Results.Length > 0)
results = String.Format("Latitude: {0}\nLongitude: {1}",
geocodeResponse.Results[0].Locations[0].Latitude,
geocodeResponse.Results[0].Locations[0].Longitude);
else
results = "No Results Found";
return results;
}发布于 2016-06-01 16:23:05
看起来您正在为Bing Maps使用非常旧的SOAP服务。必应地图团队早在6年前就不再推荐使用这些地图了。Bing地图的REST服务速度更快,功能更多,并且会定期更新。有关REST服务的文档可在此处找到:https://msdn.microsoft.com/en-us/library/ff701713.aspx
这里有关于如何在.NET中使用REST服务的文档:https://msdn.microsoft.com/en-us/library/jj819168.aspx
我还建议在这里查看最佳实践文档:https://msdn.microsoft.com/en-us/library/dn894107.aspx
https://stackoverflow.com/questions/37561195
复制相似问题