I want display only a certain area on a map. I tried using WindowRect WindowZoom and WindowScale.
Could any one gives me an example?
thanks in advance
Could any one help me please?
You can determine the outer bounds of the elements you want to display and set that to the window rect. For example, with the states sample if I call this on imported:
private void usaLayer_Imported(object sender, MapLayerImportEventArgs e) { double minY = double.MaxValue; double maxY = double.MinValue; double minX = double.MaxValue; double maxX = double.MinValue; foreach (MapElement ele in (sender as MapLayer).Elements) { if (ele.Name == "Iowa" || ele.Name == "Indiana") { minY = Math.Min(minY, ele.WorldRect.Top); maxY = Math.Max(maxY, ele.WorldRect.Bottom); minX = Math.Min(minX, ele.WorldRect.Left); maxX = Math.Max(maxX, ele.WorldRect.Right); } } if ((sender as MapLayer).Elements.Count > 0) { theMap.WindowRect = new Rect(minX, minY, maxX - minX, maxY - minY); } }
It will snap the screen to contain Iowa and Indiana.
-Graham