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
http://community.infragistics.com/forums/p/37528/222726.aspx#222726
Hello,
I am using SQL Server 2008 spatial to map US Counties. I tried using your code to determine outer bounds of the elements, but all of the elements have the same WorldRect value. The value is the same as the WorldRect value for the map. Any idea why this is happening?
I am using SQL Server 2008 spatial to map PA Counties.
Thanks!
Jason
Imported will get called multiple times indicating the status of the mapfile import, so you could display a status bar. It will have an action of
MapLayerImportAction.End
when it is finished importing.
I also found Imported got called multiple times.
Would you please explain why Imported can often get called multiple times?
Imported can often get called multiple times, if you are debugging, its best to wrap your logic in a conditional that the element count is greater than 0.