I am calculating the bounding rectangle of all symbols I am plotting on my map's symbol layer, and I want the initial zoom to be the level which just covers this.
I can set the map's WindowRect and WorldRect to my bounding rectangle, but this doesn't allow me to zoom out.
Perhaps I can use ZoomToScale? I don't know, because there is no worthwhile documentation that I can find. Same story with WindowRect and WorldRect. Perhaps a blog post explaining how all these properties and methods fit together would help?
How about a ZoomToExtent feature in a future release? Ideally this would have an optional "margin" argument.
Thanks,Col
Hi Col,
Please take a look at the following forum threads:http://forums.infragistics.com/forums/p/51936/271068.aspxhttp://forums.infragistics.com/forums/t/61558.aspx
Hope that helps,Milana Zhileva
OK, so I'm getting really frustrated by this now...
If I create an invisible surface element on a separate layer using the points of my bounding rectangle, and call WindowFit(myNewSurfaceElement) from the Imported event of my Shape layer, it sort of works*. But I can't call it in my map's Loaded event when I'm setting the map coords etc., presumably because it's too early and the element hasn't been rendered or something. The element exists in Layer.Elements but calling WindowFit on it doesn't do anything (and the element doesn't show up if I actually make it visible).
Is there an event after Loaded which I can use to call WindowFit(...) on? I could really do with some support from Infragistics on this in the absence of usable documentation.
* this is no solution as each time I pan/zoom my map, it causes new shapes to be downloaded and hence the Imported event is fired each time and my map is panned/zoomed back to where I was. It does prove that it's possible if one can get the timing correct.
so the more I look at this, the more it seems like I should be using the WindowScale property. Hence my code is now:
xamMap.WindowRect = GetRecForLatitudeLongitude(-180, 70, 180, -70); xamMap.WorldRect = xamMap.WindowRect; ShapeMapLayer.WorldRect = xamMap.WorldRect; SymbolMapLayer.WorldRect = xamMap.WorldRect; xamMap.WindowCenter = boundingRectangle.GetCenter(); xamMap.WindowScale = 500;
boundingRectangle is just what it sounds like - the rectangle which bounds the extent of the symbols on my SymbolMapLayer. By placing a textbox and button below my map, I am able to see what the current WindowScale property is and reset it. 500 happens to be about the correct figure for what I want to see in my example. Despite the WindowScale being reported as being 500 when the map loads, the map is still zoomed out to the maximum. When clicking the button to update the WindowScale to 500, it actually does it...
Is this a bug?
Col
ps - I have yet to figure out how to calculate the correct figure for WindowScale