MapsUI polygon blocks mapClick

Viewed 121

I have a layer with a number of polygons, where the layer is marked as NOT being an infolayer

myLayer = new Layer() { IsMapInfoLayer = false...

I also have an eventhandler for clicking the map defined in the xaml

MapClicked="myClickHandler"

This click works well on empty areas, but if I click a polygon, the map click is blocked. Previously I solved this by responding to the info event handler for the polygons and route that to the same code that handled map clicks, but that is not enough now, as I need the lat,lng of the clicked position.

How do I make the polygons not intercept my click?

1 Answers

If a feature is clicked the MapInfo event is called. If not the MapClicked event is called. This is by design. You mention IsMapInfoLayer is set to false. In that case no MapInfo event should be triggered and you should get a MapClicked event. Note, that the MapInfo event could also be triggered from another layer.

A workaround for your problem: The MapInfo event also contains the WorldPosition but it is on SphericalMercator coordinates. You can translate that with:

var latLon = Projection.SphericalMercator.ToLonLat(point.X, point.Y);

Related