I have a click event on the map. I do check all InformationLayers and if there is a KML Layer (MapPolygon Items) I select the item.
However the location from eventArgs. The location does not seam to be the right one. I click on a Polygon but a Polygon somewhere on the roght top corner of the image gets selected and so on.
Why is there a shift of the location? Any hints? Thanks for any replies..
void
ApMap_MapMouseClick(
object
sender, MapMouseRoutedEventArgs eventArgs)
{
switch
(_activeTool.ToolType)
{
case
ToolType.Pan:
break
;
case
ToolType.Zoomin:
break
;
case
ToolType.Zoomout:
break
;
case
ToolType.Info:
break
;
case
ToolType.Select:
foreach
(var serviceLayer
in
ServiceLayers)
{
if
(serviceLayer.Visible && serviceLayer.TypeId==1)
{
var iLyr = ApMap.Items.OfType<InformationLayer>().Where(rv => rv.Name == serviceLayer.Name).First();
var items = iLyr.GetItemsInLocation(eventArgs.Location);
if
(items.Count()>0)
{
((MapPolygon) items.First()).Fill =
new
SolidColorBrush(Color.FromArgb(127, 255, 25, 0));
((MapPolygon) items.First()).Stroke =
new
SolidColorBrush(Colors.Red);
}
}
}
break
;
default
:
throw
new
ArgumentOutOfRangeException();
}
}