Excellent.This is what I wanted to getThank you so much
Hi jcsanchezr,
Try the following:
private void xamMap_ElementClick(object sender, MapElementClickEventArgs e){ xamMap.WindowCenter = GetCenter(e.Element.WorldRect); xamMap.WindowZoom += 2.0;}
public static Point GetCenter(Rect rect){ return new Point(0.5 * (rect.Left + rect.Right), 0.5 * (rect.Bottom + rect.Top));}
WindowFit won't work in your scenario, because each MapElement has different WorldRect hence the WindowScale will be different depending on that which MapElement is clicked.
Regards,
Ivan Kotev
El codigo que uso es:
Private Sub xamMap_WindowRectChanged(ByVal sender As Object, ByVal e As Infragistics.Controls.Maps.MapWindowRectChangedEventArgs) Dim map As XamMap = DirectCast(sender, XamMap) If Math.Round(map.ScaleToZoom(e.WindowScale)) < 3 Then Me.PanelColorAutonomias.Visibility = Windows.Visibility.Visible Me.PanelColorProvincias.Visibility = Windows.Visibility.Collapsed Me.PanelColorComarcas.Visibility = Windows.Visibility.Collapsed ElseIf (Math.Round(map.ScaleToZoom(e.WindowScale)) >= 3) And Math.Round(map.ScaleToZoom(e.WindowScale)) < 6 Then Me.PanelColorAutonomias.Visibility = Windows.Visibility.Collapsed Me.PanelColorProvincias.Visibility = Windows.Visibility.Visible Me.PanelColorComarcas.Visibility = Windows.Visibility.Collapsed ElseIf Math.Round(map.ScaleToZoom(e.WindowScale)) >= 6 Then Me.PanelColorAutonomias.Visibility = Windows.Visibility.Collapsed Me.PanelColorProvincias.Visibility = Windows.Visibility.Collapsed Me.PanelColorComarcas.Visibility = Windows.Visibility.Visible End If
The problem is that e.WindowScale returns a different value depending on the method you use
The difference is the zoom, when you click on the map and runs the windowFit method, the map is bigger than if I use control and change the scale MapNavigationPane
XamMap's ScaleToZoom converts a window scale to a zoom value. You mentioned that you are using it "To view the current scale...", but this will return the current zoom level. Could to check if this is causing the issue ? If not can you post a sample code ?
Thanks,
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