使用Geocode.Core获取WPF C#应用程序中的当前位置

问题描述 投票:0回答:1

我正在尝试获取我的win7 PC当前位置的lat / lng,我正在使用Bing地图。我和SO C#聊天室里的人聊了几句话,他们告诉我关于this github项目的事。现在我已经下载了NuGet组件:Geocoding.CoreGeocoding.Microsoft

在提供的示例中,IGeocoder应该实例化如下:

IGeocoder geocoder = new GoogleGeocoder() { ApiKey = "this-is-my-optional-google-api-key" };

现在我要做的是使用MicrosoftGeocoder代替。但IDE似乎没有这种构造函数,new关键字不会给我这个选项。这是我的代码:

public MainWindow()
    {
        InitializeComponent();
        MainMap.Mode = new AerialMode(true);
        MainMap.Focus();
        MainMap.Culture = "ar-sa";
        MainMap.MouseDoubleClick += new MouseButtonEventHandler(MapWithPushpins_MouseDoubleClick);
        IGeocoder geocoder = new MicrosoftGeocoder("KEY HERE");
    }

我应该说我没有处理过github,所以如果我错过了什么,请原谅我的无知。

c# wpf bing-maps
1个回答
1
投票

MicrosoftGeocoder中没有Geocoding.Microsoft类型,但BingMapsGeocoder的构造函数接受一个键:

IGeocoder geocoder = new BingMapsGeocoder("KEY HERE");
© www.soinside.com 2019 - 2024. All rights reserved.