Is there a way to get a custom location with pin when a user tap on a certain location in the map api of windows phone 8
0
votes
What do you mean by "custom location with pin" Can u pls explain
– Prasanna Aarthi
Like get the lat,long of a certain location and pin means a marker/pushpin
– RonPelayo
You need to use map events msdn.microsoft.com/en-us/library/windowsphone/develop/… to get geo coordinates of tapped location
– Prasanna Aarthi
thanks for replying I'll check that out :D
– RonPelayo
1 Answers
2
votes
Not sure with it, but you can give it a try.
Subscribe to MouseLeftButtonDownEvent event of the map control you are using.
And in that event get the tapped point position like this.
private void myMap_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
Point p1 = e.GetPosition(myMap);
}
Now map in wp8 supports methods to convert View Port Coordinate to Geo Coordinate and vice versa, The former is the one you are looking for.
Add one more to the event handler. And your event handler would look like this.
private void myMap_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
Point p1 = e.GetPosition(myMap);
GeoCoordinate gc= myMap.ConvertViewportPointToGeoCoordinate(p1);
}
Now as you have got the GeoCoordinates you can easily put pushpin on that location.
Hope this helps