ThinkGeo.com    |     Documentation    |     Premium Support

Trouble modifying zoom levels

Hello,

I am using mapsuite web version 7.0.0.0. I am trying to simply modify the zoom levels to a lower level than the defaults. I would like the my Bing overlay to just go blank after zooming lower than than the current/default level 20 and I have a custom overlay with some images that would be able to be zoomed further. I have tried changing the scales of the default zoom levels as well as creating a custom zoom level set basedon the bingzoomlevelset and then adding a few additional levels. Nothing seems to change the client behavior. Is there a bug in 7.0 or am I missing something?

Hi David, 



What I am guessing is whether you are using the BingOverlay as the background layer, if yes, I guess that’s the root of the issue. The overlays like BingOverlay,GoogleOverlay,YahooOverlay can’t work with the custom zoom level, as their zoom levels are fixed and Open layers zoom levels will always base on them. that’s the reason why the PanZoomBar is always the default, which the max zoomlevel is only 19 or 20 zoom levels and we can’t zoom into further, which means the zoom level beyond 19 or 20 will never be used. 



Here is a workaround for it. We can use the BingMapLayer instead of BingOverlay when adding  the additional levels. The attached file includes the partial codes to show the details. Please check it out. 

Thanks

001_customZoomlevel.txt (1.77 KB)

So if i user google map ?

Hi Tran,



Welcome to Map Suite Forums!

Actually, there is a better way to zoom into further over Google Or Bing map and don’t need to use the workaround with BingMapLayer or GoogleMapLayer . Please try the attached sample:



In client side:


<script type=<code style=“color: blue;”>“text/javascript”<code style=“color: #000000;”>>
       function OnOverlaysDrawing(layers) {
 
           for (var index = 0; index < layers.length; index++) {
               var templayer = layers[index];
               if (OpenLayers.String.contains(templayer.CLASS_NAME, ‘Google’)) {
                   templayer.options.numZoomLevels = 24;
                   templayer.options.maxZoomLevels = 24;
 
                   templayer.MIN_ZOOM_LEVEL = 0;
                   templayer.MAX_ZOOM_LEVEL = 24;
                   templayer.RESOLUTIONS.push(templayer.RESOLUTIONS[21] / 2);
                   templayer.RESOLUTIONS.push(templayer.RESOLUTIONS[22] / 2);
                   templayer.RESOLUTIONS.push(templayer.RESOLUTIONS[23] / 2);
               }
               if (OpenLayers.String.contains(templayer.CLASS_NAME, ‘Bing’)) {
                   templayer.options.numZoomLevels = 24;
                   templayer.resolutions.push(templayer.resolutions[19] / 2);
                   templayer.resolutions.push(templayer.resolutions[20] / 2);
                   templayer.resolutions.push(templayer.resolutions[21] / 2);
                   templayer.resolutions.push(templayer.resolutions[22] / 2);
               }
           }
       }
   </script>

Sever side:


Map1.ZoomLevelSet = CustomZoomlevelSets();

private ZoomLevelSet CustomZoomlevelSets()
        {
            ZoomLevelSet myZoomlevelset = new ZoomLevelSet();
 
            GoogleMapsZoomLevelSet googlezoomlevelsets = new GoogleMapsZoomLevelSet();
            foreach (ZoomLevel item in googlezoomlevelsets.GetZoomLevels())
            {
                myZoomlevelset.CustomZoomLevels.Add(item);
            }
 
            ZoomLevel zoomlevel21 = new ZoomLevel(myZoomlevelset.GetZoomLevels()[myZoomlevelset.GetZoomLevels().Count - 1].Scale / 2);
            ZoomLevel zoomlevel22 = new ZoomLevel(zoomlevel21.Scale / 2);
            ZoomLevel zoomlevel23 = new ZoomLevel(zoomlevel22.Scale / 2);
            ZoomLevel zoomlevel24 = new ZoomLevel(zoomlevel23.Scale / 2);
            myZoomlevelset.CustomZoomLevels.Add(zoomlevel21);
            myZoomlevelset.CustomZoomLevels.Add(zoomlevel22);
            myZoomlevelset.CustomZoomLevels.Add(zoomlevel23);
            myZoomlevelset.CustomZoomLevels.Add(zoomlevel24);
 
            return myZoomlevelset;
        }

Hope it helps.

Regards,

Troy


Hi Tran,



Welcome to Map Suite Forums!
Actually, there is a better way to zoom into further over Google Or Bing map and don’t need to use the workaround with BingMapLayer or GoogleMapLayer . Please try the attached sample:



Client side:


<script type=<code style=“color: blue;”>“text/javascript”<code style=“color: #000000;”>>
        function OnOverlaysDrawing(layers) {
 
            for (var index = 0; index < layers.length; index++) {
                var templayer = layers[index];
                if (OpenLayers.String.contains(templayer.CLASS_NAME, ‘Google’)) {
                    templayer.options.numZoomLevels = 24;
                    templayer.options.maxZoomLevels = 24;
 
                    templayer.MIN_ZOOM_LEVEL = 0;
                    templayer.MAX_ZOOM_LEVEL = 24;
                    templayer.RESOLUTIONS.push(templayer.RESOLUTIONS[21] / 2);
                    templayer.RESOLUTIONS.push(templayer.RESOLUTIONS[22] / 2);
                    templayer.RESOLUTIONS.push(templayer.RESOLUTIONS[23] / 2);
                }
                if (OpenLayers.String.contains(templayer.CLASS_NAME, ‘Bing’)) {
                    templayer.options.numZoomLevels = 24;
                    templayer.resolutions.push(templayer.resolutions[19] / 2);
                    templayer.resolutions.push(templayer.resolutions[20] / 2);
                    templayer.resolutions.push(templayer.resolutions[21] / 2);
                    templayer.resolutions.push(templayer.resolutions[22] / 2);
                }
            }
        }
    </script>

Sever side:


Map1.ZoomLevelSet = CustomZoomlevelSets();

private ZoomLevelSet CustomZoomlevelSets()
        {
            ZoomLevelSet myZoomlevelset = new ZoomLevelSet();
 
            GoogleMapsZoomLevelSet googlezoomlevelsets = new GoogleMapsZoomLevelSet();
            foreach (ZoomLevel item in googlezoomlevelsets.GetZoomLevels())
            {
                myZoomlevelset.CustomZoomLevels.Add(item);
            }
 
            ZoomLevel zoomlevel21 = new ZoomLevel(myZoomlevelset.GetZoomLevels()[myZoomlevelset.GetZoomLevels().Count - 1].Scale / 2);
            ZoomLevel zoomlevel22 = new ZoomLevel(zoomlevel21.Scale / 2);
            ZoomLevel zoomlevel23 = new ZoomLevel(zoomlevel22.Scale / 2);
            ZoomLevel zoomlevel24 = new ZoomLevel(zoomlevel23.Scale / 2);
            myZoomlevelset.CustomZoomLevels.Add(zoomlevel21);
            myZoomlevelset.CustomZoomLevels.Add(zoomlevel22);
            myZoomlevelset.CustomZoomLevels.Add(zoomlevel23);
            myZoomlevelset.CustomZoomLevels.Add(zoomlevel24);
 
            return myZoomlevelset;
        }

Hope it helps.

Regards,

Troy




CustomZoomlevelForBingGoogle.zip (2.23 KB)