Search code examples
uwpuwp-maps

UWP Map - get a MapElement under Pointer


I have code that adds custom MapPolylines to the MapControl, to its MapElements collection. They are displayed fine, but is there a way to detect any MapPolyline which is currently under the Pointer? I want to be able to delete any single MapPolyline, not to clear the whole MapElements collection.


Solution

  • You can register for the MapElementPointerEntered event https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.maps.mapelementslayer or use FindMapElementsAtOffset https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.maps.mapcontrol