Does anyone have any insight into how to implement a draggable pushpin on a map on a WP7 client running Mango? I have a pushpin bound to a geo-location on a map and I want the user to be able to drag it on a map and record its new location. I've seen some resources, but they're for non-WP7 Bing Maps control. Any help would be appreciated.
Thanks!
e.GetPosition(element) gives the position relative to the element passed on the parameter. Also, the point to convert using ViewportPointToLocation has to be relative to the position of the map. So, you have to do the following:
You want to have the origin of your UI element not your finger right? Try this:
If anyone is curious, this is the solution I came up with:
XAML:
.cs:
Does anyone have any ideas on how to extract the geocoordinates of the pushpin's new location?? I tried the code below in the event handler and it doesn't give correct coordinates:
myPin.location gives the old coordinates
I know this is a late response but I was working on a similar project and using a similar approach, so I thought I'd share. This is my first post so bare with me but my approach that I used was:
Create two global double variables to hold X,Y coord's:
Set these global doubles to the location of the point of your pushpin in your DragStarted event:
In your dragDelta event, change these variables as your would your pushpin:
Now on DragCompleted create a new point that takes in our rendered global variables, and map them to a geocoordinate, and here's the kicker; Remove our old pin from the ObservableCollection (Mine is Locations) and add in a new pushpin at our new coordinate:
Hope this helps