Get Information(Lat,Lon) of Clicked Marker in WPF

Mar 26, 2010 at 3:38 PM

Hi Radioman,

I create markers step by step on my map, and I want to get Latitude and Longtitude Information of these created markers to delete selected one. I must first reach click event of these markers.   You created icon LeftButtonDown event at CustomMarkersDemo but it is not supply to me Latitude and Longtitude of that marker.

thanks.

 

Mar 26, 2010 at 8:31 PM

can you explain exactly what do you want to do? ;}

Mar 27, 2010 at 9:51 AM

I want to delete marker and its route which is selected.

Mar 27, 2010 at 1:55 PM

so you need add selected property to your custom markers

Mar 27, 2010 at 2:26 PM

Exactly :)

Mar 29, 2010 at 4:03 PM

I have three ways to solve this issue;

1 - I have more than one marker. I think I have to create an GMapMarker Array, so I can pass my GMapMarker class objects in it. Later on, I can select these objects and its properties.

2 - You created PropertyChanged event in your GMapMarker class, could this work for also selected GMapMarker objects?

3 - Or I must add SelectedMarker  EventArgs to your GMapMarker class :) 

Which way is appropriate :)  , what do you think? 

Mar 29, 2010 at 4:48 PM

Just create CustomUserControl, add bool IsSelected, use event OnMouseClick, set IsSelected = !IsSelected;, make it bigger/smaller, change color, etc. And use it as markers shape; And if you want to get all selected markers, just: var selectedMarkers = from p in map.Markers where (p as CustomUserControl).IsSelected seleted p;

..well you need experiment, in my project i've changed methods few times to achieve the same result ;}

Mar 30, 2010 at 11:43 AM

Yes, I created a CustomUserControl(as component) for just icon. I wrote properties(Lat,Lng,Image...etc.) for that icon(CustomUserControl). And Now I reach Latitude and Longtitude of any selected icon, and everything is fine at this point. 

Now I need to delete that icon(marker) and its route according to its Lat and Lng. I find a method; MainWindow.MainMap.Markers.Remove(GMapMarker), but I think it is not enough for my aim.

Is there any other methods for this purpose?

 

Mar 30, 2010 at 12:08 PM

not enough? ;D and whats wrong with it?

Mar 30, 2010 at 12:28 PM

It deletes just marker, I need to also delete its route :) .

Mar 30, 2010 at 1:20 PM

route is also marker ;}

Mar 30, 2010 at 1:49 PM

i separated routes from markers in windows forms version, but in wpf currently they are the same object

Mar 30, 2010 at 3:44 PM

Ok, In marker object, it has routes.  I wrote SelectedMarker.Map.Markers[count -1].Route.Clear(); , but it misses some points of Routes.

I want to delete just last route, because the aim is user can undo its last move, it is because count -1. Can you show me the way? 

Mar 30, 2010 at 7:40 PM

route is a marker with generated shape as path. So you have multiply routes if you miss something.

Feb 18, 2013 at 5:35 PM
How can i get lat,long position of a marker when user drags a marker from one point to other on a map

i want lat,long position of two points.

i am using currentmarker.position which gives the lat,lng position of a point after dragging is completed.

but i need the lat,lng position of marker from where it is dragged

I am using WPF