In a USA map, I want to enable highlighting and selection in only few states. How I can do that? Do I need to customize something in the map shape file? Or I can handle in code itself? Please help me.
Do you mean something like this?
Markup:
<UserControl x:Class="SilverlightApplication18.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" xmlns:igMap="clr-namespace:Infragistics.Silverlight.Map;assembly=Infragistics.Silverlight.DataVisualization.Map.v9.2">
<Grid x:Name="LayoutRoot">
<igMap:XamWebMap x:Name="theMap" ElementClick="theMap_ElementClick">
<igMap:XamWebMap.Layers>
<igMap:MapLayer Imported="MapLayer_Imported">
<igMap:MapLayer.Reader>
<igMap:ShapeFileReader Uri="ShapeFiles/usa_st" DataMapping="Name = STATE_NAME; Caption = STATE_NAME" />
</igMap:MapLayer.Reader>
</igMap:MapLayer>
</igMap:XamWebMap.Layers>
</igMap:XamWebMap>
</Grid>
</UserControl>
Code:
public partial class MainPage : UserControl
{
private Dictionary<String, Boolean> _allowedNames = new Dictionary<string, bool>();
public MainPage()
InitializeComponent();
_allowedNames.Add("New Jersey", true);
_allowedNames.Add("Alaska", true);
}
private void MapLayer_Imported(object sender, Infragistics.Silverlight.Map.MapLayerImportEventArgs e)
foreach (MapElement ele in theMap.Layers[0].Elements)
if (_allowedNames.ContainsKey(ele.Name))
ele.IsClickable = true;
ele.IsSelectable = true;
else
ele.IsClickable = false;
ele.IsSelectable = false;
private void theMap_ElementClick(object sender, MapElementClickEventArgs e)
MessageBox.Show("You clicked on: " + e.Element.Name);
Please let me know if you have any questions.
-Graham
No. Its not working. In Map_Imported event, always the Elements count is zero. So all states are always clickable and selectable.
I tried the same code in map_LayoutUpdated event, the IsClickable property is working, but when I mouseover the not allowed states, it should not highlight. But it highlights all the states.
How I can disable highlighting of a state? I dont find any properties for this. Like I want to disable some states.