Hi jcsanchezr
You can attach to XamMap's ElementClick event and then call XamMap's WindowFit method to adjust the window rectangle to fit the clicked element. E.g.:
In XAML
<Maps:XamMap x:Name="xamMap" ElementClick="xamMap_ElementClick"> <Maps:XamMap.Layers> <Maps:MapLayer x:Name="worldLayer"> <Maps:MapLayer.Reader> <Maps:ShapeFileReader Uri="ShapeFiles/world/world" DataMapping="Name=CNTRY_NAME; Caption=CNTRY_NAME; Value=POP_CNTRY" /> </Maps:MapLayer.Reader> </Maps:MapLayer>
<Maps:MapLayer VisibleFromScale="1.7" Brushes="#FF3969A5 #FF71A1DA" x:Name="statesLayer"> <Maps:MapLayer.Reader> <Maps:ShapeFileReader Uri="ShapeFiles/usamap/states" DataMapping="Name=STATE; Caption=STATE" /> </Maps:MapLayer.Reader> </Maps:MapLayer>
</Maps:XamMap.Layers>
<Maps:MapNavigationPane HorizontalAlignment="Left" />
</Maps:XamMap>
Code behind:
private void xamMap_ElementClick(object sender, MapElementClickEventArgs e){ xamMap.WindowFit(e.Element);}
Please let me know if this works for you.
Regards,
Ivan Kotev
great, is the result we wanted.
now I have another "problem"
I have 4 layers. I'm using the MapColorSwatchPane control. When I change the scale, displays one of the 4 controls MapColorSwatchPane. Use the event xamMap.WindowRectChanged to put visible or not one of the 4 controls MapColorSwatchPane. To view the current scale, use Math.round (map.ScaleToZoom (e.WindowScale))The problem is that when I change the scale manually, using the MapNavigationPane control, I returned a different scale value when using the WindowFit, so that the map show a layer and MapColorSwatchPane is associated with other layer.Can we be seeing a scale and contour of the previous scale? for example. Layer 1 shows all the countries of Europe. Layer 2 shows the cities of Europe. When you visualize the scale of 2, not unlike the country. The idea is to see the cities, but you see the outline of the countries.Thank you very much