我正在使用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;
}
答案 0 :(得分:0)
看起来您正在使用Bing Maps的旧SOAP服务。 Bing Maps团队在6年前停止推荐使用这些产品。 Bing Maps 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