0

I'm trying to get the lat/lng of my current location of my win7 PC, I'm using Bing maps. I've had some words with the guys at the SO C# chat room and they told me about this github project. Now I've downloaded the NuGet components: Geocoding.Core and Geocoding.Microsoft

In the example provided, an IGeocoder should be instantiated as follows:

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

Now what I'm trying to do is using MicrosoftGeocoder instead. But the IDE doesn't seem to have this kind of constructor, the new keyword won't give me that option. Here's my code:

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");
    }

I should say that I haven't dealt with github very much so excuse my ignorance if I'm missing something.

mm8
  • 163,881
  • 10
  • 57
  • 88
Sam Ibraheem
  • 157
  • 2
  • 13
  • There is a constructor : public GoogleGeocoder(string apiKey) So you can just use : IGeocoder geocoder = new GoogleGeocoder("this-is-my-optional-google-api-key") – jdweng Feb 19 '19 at 14:52
  • @jdweng you mean I don't have to change the map object from Bing maps to Google maps? – Sam Ibraheem Feb 19 '19 at 14:56
  • The API will automatically call the Google URL with the github project. You will not be using Bing. – jdweng Feb 19 '19 at 15:04
  • @jdweng looks like I'm gonna have a bad time using Bing Maps, thank you for your time dear this is my second question with you around trying to help – Sam Ibraheem Feb 19 '19 at 15:11

1 Answers1

1

There is no MicrosoftGeocoder type available in Geocoding.Microsoft but the constructor of BingMapsGeocoder accepts a key:

IGeocoder geocoder = new BingMapsGeocoder("KEY HERE");
mm8
  • 163,881
  • 10
  • 57
  • 88