Search code examples
windows-8locationbing-mapswindows-store-appspushpin

pushpin.Location error on Bing maps for Windows store app


I'm using C# to create a windows store app using bing maps. I am trying to store and retrieve the location of a randomly placed pushpin on a map but when I use pushpin.Location for trying to print the location for example, I get the following error:

'Bing.Maps.Pushpin' does not contain a definition for 'Location' and no extension method 'Location' accepting a first argument of type 'Bing.Maps.Pushpin' could be found (are you missing a using directive or an assembly reference?)

The simple code example below show what I mean a bit more clearly:

private async void pushpinTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
{
      MessageDialog dialog = new MessageDialog("You are here" + pushPin.Location());
      await dialog.ShowAsync();
}

It states clearly that location is a property of the the pushpin class in the API here There's also examples of it being used for windows phone 7, like in this question.

Any ideas what I'm missing? or is this functionality not available for Windows 8?


Solution

  • It works like:

    async void pin_Tapped(object sender, TappedRoutedEventArgs e)
            {
                Pushpin pin = sender as Pushpin;
                Location pinLocation = MapLayer.GetPosition(pin);
                MessageDialog dialog = new MessageDialog("You are here: " + pinLocation.Latitude +", " + pinLocation.Longitude);
                await dialog.ShowAsync();
            }