In version 2.0 there was the thresholds that allowed you to set the upper and lower limits in miles (or other map unit). With the zoom levels how do you match the levels to miles? Also, how do you display the current zoom level in which the map display is in?
Zoom Levels
Justin…
Can’t answer the first part. The second part was answered (in VB) a while ago here:
gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/22/aft/4854/afv/topic/Default.aspx
but this code doesn’t work in version 3.0. Quick-and-dirty, I’ve made it work for C# and 3.0 by doing something like this (I’m using shapefiles):
// I started a “Map_Suite_Utils” class, since I imagine there will be more of these little things as time goes by…but it could just be a function
// in your main source without the class wrapping
class Map_Suite_Utils
{
static public int GetZoomLevel(WinformsMap m)
{
ShapeFileFeatureLayer l = (ShapeFileFeatureLayer) m.StaticOverlay.Layers[0];
ZoomLevelSet z = l.ZoomLevelSet;
if (CurrentScale < z.ZoomLevel18.Scale) return (18);
if (CurrentScale < z.ZoomLevel17.Scale) return (17);
etc…
If you set a style at ONE zoom level, I think you’ll see I’m off by one level (didn’t bother to figure out why) but I correct in the app.
Allen
Hi,
I think most 2.0 users have this question. Thanks for pointing it out.
Scale vs Mile
In 2.0, the threshold (Like ZoomLevel in 3.0) allows us to set the upper/lower limits in miles, but in fact, that’s not a “right” way. First, it’s not straightforward for users. When seeing a map, people will wonder where the map is for, maybe the next concern is what the scale is. Few people are interested on the distance from east to west, a map marked with “Lawrence; 1:100000” makes much more sense than marked with “Lawrence, 10 miles from East to West”.
Second, it’s not so handy for developers. User’s request may be like this: when zooming to 1:20000, only main streets are supposed to be displayed; when zooming to 1:5000, the detail roads should be displayed. Developers then needs to convert the scale to the unit the threshold accepts, like miles or kilometers.
Another benefit for using the scale is it fits better under different map sizes. In the old way, for displaying the same area of Lawrence for example, no matter the map is displayed in a small monitor or a big screen, it displays the same thing, as the west-east distance for that area is always the same. While with scale, for the same area, we can display more detail roads in that big screen and only show major streets on that small one. The same render logic fits different screen sizes!
As a result, we added the ZoomLevel and support scale in 2.0; and for 3.0, as a revolutionary product, we get rid of the old threshold unit “miles, kilometers, etc” and uses scale only.
Here is how to get a scale from map’s extent
double scale = ExtentHelper.GetScale(CurrentExtent, MapWidth, GeographyUnit.DecimalDegree);
Here is how to get a scale for the map in which the distance from west to east is 100 kilometers long, the map.Width is 800 pixel, and the DPI is 96pixel/inch for example.
100 * 1000 / (800 / 96 * 2.54 * 0.01) = 472440 : 1 (1 inch = 2.54 centimeters)
BTW: besides scale, there is another interesting unit: Altitude, we might support it in the future.
ZoomLevelSet vs Threshold
We know a layer is usually rendered in different ways when zooming in or out. In 2.0, we set render logics in thresholds and add them to layer; in 3.0, you cannot create an isolated ZoomLevel though, instead, you need to create a ZoomLevelSet including all the possible zoomLevels and apply it to the layer. One reason is isolated threshold is easier to make mistakes, unexpected overlap or gap between thresholds happens quite a lot. Also it is easier to have some predefined ZoomLevel and we just pick one up, people do not need to figure out what the extent of this threshold will be. We provide 20 popular zoomLevels which you can set the style directly, and expand the settings to different ZoomLevel easily (by property ApplyToZoomLevel).
RasterLayer is much simpler as it only has 2 status (display or not display), so in 3.0, we have 2 properties to set a simple ZoomLevel of a RasterLayer. (RasterLayer.UpperExtent and RasterLayer.LowerExtent), that meets most of the cases.
If you want to update a threshold in 2.0 to ZoomLevelSet, the best way is to find the corresponding ZoomLevels within default ZoomLevelSet. For example 2 thresholds are added to a layer, maybe the corresponding ZoomLevel is ZoomLevel01 to ZoomLevel07 for Threshold1, ZoomLevel08 to ZoomLevel14 for threshold 2. The other way is to create a new ZoomLevelSet and apply that one to the layer. That’s a bit difficult and not recommended for most cases.
Here is the method to get the current ZoomLevel
public ZoomLevel ZoomLevelSet.GetZoomLevel(RectangleShape extent, double screenWidth, GeographyUnit mapUnit)
I hope that helps. Any queries please let us know.
Ben.