I am currently adding multiple Images and Map Symbols to a Map. The Map Symbols are clickable and work fine but the Images are not clickable. Tried messing with setting IsHitTestVisible on the maplayer and even the Image Element but doesn't seem to have any effect.
Xaml snippet.
<igMap:XamMap x:Name="xamMap2" Visibility="Collapsed"> <igMap:XamMap.Layers> <igMap:MapLayer x:Name="MapLayer" IsAutoWorldRect="True" Imported="MapLayer_Imported"> <igMap:MapLayer.ValueTemplate> <DataTemplate> <Image Width="16" Height="16" xmlns:local="clr-namespace:Test;assembly=Test" Source="{Binding Path=(local:MapData.ValueData)}" /> </DataTemplate> </igMap:MapLayer.ValueTemplate> </igMap:MapLayer> </igMap:XamMap.Layers> </igMap:XamMap>
In the MapLayer_Imported I loop thru the returned records and add the images.
'New Element element = New SymbolElement() element.Name = "Test"
'Set Position element.SymbolOrigin = New Point(20,20))
'Set Image Path MapData.SetValueData(element, New Uri("/Images/" & ImageName, UriKind.Relative))
element.IsClickable = True element.IsSelectable = True element.IsSensitive = True
'Add to Map Layer xamMap2.Layers(0).Elements.Add(element)
Hi Rob,
Try to attach to Image's MouseLeftButtonDown. I have built a sample from your code:
In XAML
<igMap:XamMap x:Name="xamMap1"> <igMap:XamMap.Layers> <igMap:MapLayer x:Name="MapLayer" IsAutoWorldRect="True" > <igMap:MapLayer.Reader> <igMap:ShapeFileReader Uri="Shapefiles/world/world" /> </igMap:MapLayer.Reader>
<igMap:MapLayer.ValueTemplate> <DataTemplate> <Image Width="32" Height="32" MouseLeftButtonDown="Image_MouseLeftButtonDown" Source="pizza.png" /> </DataTemplate> </igMap:MapLayer.ValueTemplate> </igMap:MapLayer> </igMap:XamMap.Layers></igMap:XamMap>
Code behind:
private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e){ Debug.WriteLine("Image_MouseLeftButtonDown");}
Please let me know if it works for you.
Regards
Ivan Kotev
Hi, with mouseleftbuttonddown event how can we get the value of clicked element..