Let's say I load a raster with a world file. How do I limit the ability to zoom out to be a maximum of twice the 'natural' extents of the raster? That is, I don't want the user to be able to zoom way way out, but to limit it so that at max zoom out, the largest dimension of the raster (X or Y) is 50% of the available map dimension in that same direction.
Thanks for your post and question. Take a try on the following event, following is the code snippet you can reference, hope it can help.
winformsMap1.CurrentExtentChanging += new EventHandler<CurrentExtentChangingWinformsMapEventArgs>(winformsMap1_CurrentExtentChanging);
void winformsMap1_CurrentExtentChanging(object sender, CurrentExtentChangingWinformsMapEventArgs e) { // You have to modify the condition here. if (e.CurrentExtent.LowerLeftPoint.X > new RectangleShape(-118.098, 84.3, 118.098, -84.3).LowerLeftPoint.X) { e.Cancel = true; } }
Any more questions please feel free to let me know.
Thank you Yale, but I had a different approach in mind, tho I probably have an incomplete understanding of the zoom function.
Is it possible to set the area shown by ZoomLevel1 to some calculated boundries larger than the loaded raster (don't worry about that calculation exactly) so that ZoomLevel1 (or 20?) represents the maximum zoom out I described? Then the other zoom levels would just work 'in' from there?
If I am not misunderstanding anything, your approach is likely to create customized zoomlevels, I agree that this will work while it is something we need to consider carefully about the scale values.
Any more questions please feel free to let me know.
The Map.CurrentScale is calculated by the static API GetScale provided in the ExtentHelper class, it need to input the map current extent and the map with and mapunit.
Any more questions please feel free to let me know.