我已经将SOAP服务添加到我的C#项目中,并围绕它创建了一个小应用程序来测试bing out。除了GeocodeServiceClient之外,一切都很好。从我找到的每个示例中,以下内容都很好
var geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");但是,当我开始构建时,我发现GeocodeServiceClient需要两个参数。进一步研究,基类似乎需要第二个参数
public GeocodeServiceClient(EndpointConfiguration endpointConfiguration)
: base(GeocodeServiceClient.GetBindingForEndpoint(endpointConfiguration), GeocodeServiceClient.GetEndpointAddress(endpointConfiguration))
{
}我需要传入的第二个参数是什么?
为了完整起见,下面是我使用的代码
void GeocodeAddress(string address)
{
var geocodeRequest = new GeocodeRequest
{
Credentials = new Credentials
{
ApplicationId = App.Self.APIKEY,
},
Query = address,
Address = new Address()
};
var filters = new ConfidenceFilter[1];
filters[0] = new ConfidenceFilter();
filters[0].MinimumConfidence = Confidence.High;
var geocodeOptions = new GeocodeOptions
{
Filters = new ObservableCollection<FilterBase>(filters)
};
geocodeRequest.Options = geocodeOptions;
var geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
var myLoc = new Location();
geocodeService.GeocodeCompleted += async (object sender, GeocodeCompletedEventArgs e) =>
{
if (e.Error == null)
{
if (e.Result.Results.Length > 0)
if (e.Result.Results[0].Locations.Length > 0)
{
myLoc = e.Result.Results[0].Locations[0];
var uri = await Map.GetMapUri(myLoc.Latitude, myLoc.Longitude, 2, "HYBRID", 300, 300);
await Navigation.PushAsync(new Map(uri));
}
}
};
geocodeService.GeocodeAsync(geocodeRequest);
}发布于 2015-05-20 04:51:52
不要使用遗留的Bing Maps SOAP服务。它们很老,很慢,而且很多年没有更新过了。该服务的文档甚至不再在线。该服务在5年前被Bing Maps REST服务取代。您可以在此处找到有关Bing地图REST服务的信息:
https://msdn.microsoft.com/en-us/library/ff701713.aspx
您可以在.NET中找到有关使用这些服务的文档:
https://stackoverflow.com/questions/30153338
复制相似问题