ThinkGeo.com    |     Documentation    |     Premium Support

Custom zoom levels

I have a trackbar on my window to allow users to customize the zoom level. The middle point of the trackbar is the default zoom level, which is approximately zoom level 20.


The map is configured to not snap to the zoom level.


 I would like to specify custom scales at each tick on the trackbar. I calculate each zoom level by dividing the scale for zoom level 20 by 2. When the trackbar moves to that tick, I set the CurrentScale property to match the value I calculate for the tick.


Further, if the user changes the zoom level using the mousewheel or zoom-to, I try to calculate the current scale to see which scale they've zoomed to, and adjust the trackbar setting accordingly.


The problem arises that I can try to set the CurrentScale to my calculated value but the CurrentScale won't change. For example, I can set the CurrentScale to 141 but the map scale never adjusts to that value.


What's the best way to calculate the zoom levels (beyond 20) and ensure that the mousewheel and zoom-to behavior matches my zoom levels?



Gregory,


I am not sure you have set the MimumScale of the map control to below the value you want to adjust to:



winformsMap1.MinimumScale = 100;



Also, I suggest another way to do is by using the API ZoomToScale:



winformsMap1.ZoomToScale(141);

Any more questions just feel free to let me know.


Thanks.


Yale

 



Thanks, Yale, but I guess the issue I’m having is that I  need to know what the precise zoom levels are. If I tell the map to ZoomToScale(141) it has no effect unless I use some specific numeric value with 8 decimal points, like 141.989896659. How do I calculate these zoom levels lower than zoom level 20? Also, how can I force the mousewheel and zoomto to honor these zoom levels?

Gregory,


As I understand so far, you have turned off the ZoomLevelSnapping for your Map Control by setting:



winformsMap1.ZoomLevelSnapping = ZoomLevelSnappingMode.None;

Then you could set your own ZoomLevel scale to any reasonable number regardless of its precisions.




If you want to the Mousewheel control the customized zoomlevel scales, you have to use the CustomZoomLevel instead, following is the code snippet:



winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(testZoomLevelSet.ZoomLevel03.Scale));
winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(testZoomLevelSet.ZoomLevel05.Scale));
winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(testZoomLevelSet.ZoomLevel10.Scale));
winformsMap1.ZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(testZoomLevelSet.ZoomLevel20.Scale));

Our default logic is the next zoomLevel scale is half of its previous one, for example:

zoomLevel20 scale : 1126.4644432067871;

zoomLevel19 scale : 2252.9288864135742;

etc..


If you still have problem, could you send me a small sample application to show your problem?


Any more questions just feel free to let me know.


Thanks.


Yale