0

I'm currently trying to develop an simple application that allows user to add new pushpins. I'm currently using following code to add new pushpins,

        Pushpin pushpin1 = new Pushpin();

        pushpin1.GeoCoordinate = MyGeoPosition;
        pushpin1.Content = "My car";
        MapOverlay overlay1 = new MapOverlay();
        overlay1.Content = pushpin1;
        overlay1.GeoCoordinate = MyGeoPosition;
        layer1.Add(overlay1);

        myMap.Layers.Add(layer1);

But, to use this code, I need the latitude and longitude of the location that user has selected. So how can I get the latitude and longitude of the location that user has selected. (Simply geo-coordinate) I know I need to write a event handler, But I don't know the way that it has to be implemented... Thank you...

user9480
  • 324
  • 1
  • 13

2 Answers2

0

There are multiple map events like

CenterChaged, MapTapped

you can handle those events to add your push pin. here is MapTapped example

 async private void map_MapTapped(MapControl sender, MapInputEventArgs args)
    {
       var MyGeoPosition = args.Location;
      //....
    }
Muhammad Saifullah
  • 4,292
  • 1
  • 29
  • 59
0

Try This

MapA = new Map();
MapA.Tap += MapA_Tap;

void MapA_Tap(object sender, System.Windows.Input.GestureEventArgs e)
    {
         GeoCoordinate location = MapA.ConvertViewportPointToGeoCoordinate(e.GetPosition(MapA));

 //display pushpin by using location.latitude and location.longitude
}
Query21
  • 200
  • 2
  • 10