首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >必应GeocodeServiceClient需要2个参数

问必应GeocodeServiceClient需要2个参数
EN

Stack Overflow用户
提问于 2015-05-10 23:44:39
回答 1查看 244关注 0票数 0

我已经将SOAP服务添加到我的C#项目中,并围绕它创建了一个小应用程序来测试bing out。除了GeocodeServiceClient之外,一切都很好。从我找到的每个示例中,以下内容都很好

代码语言:javascript
复制
var geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");

但是,当我开始构建时,我发现GeocodeServiceClient需要两个参数。进一步研究,基类似乎需要第二个参数

代码语言:javascript
复制
public GeocodeServiceClient(EndpointConfiguration endpointConfiguration)
        : base(GeocodeServiceClient.GetBindingForEndpoint(endpointConfiguration), GeocodeServiceClient.GetEndpointAddress(endpointConfiguration))
    {
    }

我需要传入的第二个参数是什么?

为了完整起见,下面是我使用的代码

代码语言:javascript
复制
    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);
    }
EN

回答 1

Stack Overflow用户

发布于 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://msdn.microsoft.com/en-us/library/jj819168.aspx

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30153338

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档