Bing GeocodeServiceClient需要2个参数

时间:2015-05-10 15:44:39

标签: c# bing-maps

我已将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);
    }

1 个答案:

答案 0 :(得分:0)

不要使用传统的Bing Maps SOAP服务。它们陈旧,缓慢,并且多年来一直没有更新。该服务的文档甚至不再在线。 5年前,Bing Service REST服务取代了这项服务。您可以在此处找到有关Bing Maps REST服务的信息:

https://msdn.microsoft.com/en-us/library/ff701713.aspx

您可以在此处找到有关在.NET中使用这些服务的文档:

https://msdn.microsoft.com/en-us/library/jj819168.aspx