ThinkGeo.com    |     Documentation    |     Premium Support

Custom zoom level not working in MVC Map

Hello,



I have issue with custom zoom level. I have passed my custom zoom level to map and only set it to ZoomLevel11. but it still allow me to zoom to level 20.




Map map = new Map("Map1"new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage), 570);
map.MapBackground = new BackgroundLayer(new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF")));
map.MapUnit = GeographyUnit.Meter;
map.ZoomLevelSet = GetCustomZoomLevelSet();
map.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level11;

And my function for custom zoom level is 




public ZoomLevelSet GetCustomZoomLevelSet()
       {
           ZoomLevelSet customZoomLevelSet = new ZoomLevelSet();
           customZoomLevelSet.ZoomLevel01.Scale = 1000000;
           customZoomLevelSet.ZoomLevel02.Scale = 500000;
           customZoomLevelSet.ZoomLevel03.Scale = 250000;
           customZoomLevelSet.ZoomLevel04.Scale = 125000;
           customZoomLevelSet.ZoomLevel05.Scale = 62500;
           customZoomLevelSet.ZoomLevel06.Scale = 31250;
           customZoomLevelSet.ZoomLevel07.Scale = 15625;
           customZoomLevelSet.ZoomLevel08.Scale = 7812.5;
           customZoomLevelSet.ZoomLevel09.Scale = 3906.25;
           customZoomLevelSet.ZoomLevel10.Scale = 1953.125;
           customZoomLevelSet.ZoomLevel11.Scale = 976.5625;
           //customZoomLevelSet.ZoomLevel12.Scale = 0;
           //customZoomLevelSet.ZoomLevel13.Scale = 0;
           //customZoomLevelSet.ZoomLevel14.Scale = 0;
           //customZoomLevelSet.ZoomLevel15.Scale = 0;
           //customZoomLevelSet.ZoomLevel16.Scale = 0;
           //customZoomLevelSet.ZoomLevel17.Scale = 0;
           //customZoomLevelSet.ZoomLevel18.Scale = 0;
           //customZoomLevelSet.ZoomLevel19.Scale = 0;
           //customZoomLevelSet.ZoomLevel20.Scale = 0;
           return customZoomLevelSet;
       }

But still when I zoom in on map it allow me to zoom up to level 20. and also it shows me different zoom scale than what I have passed to my custom zoom level function.



Please check my code and let me know if I made some mistake in this.



Thank you.

Eric.

Hi
Eric,


The
code in your method just modify the scale of ZoomLevel01, 02 and to 11, but the
zoomlevel count of this ZoomLevelSet never changed. The right way is adding
zoomlevels to CustomZoomLevels of customZoomLevelSet. Would you please try
below code?


           
ZoomLevelSet customZoomLevelSet =
new ZoomLevelSet();


    
     customZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(1000000));


           
customZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(500000));


           
customZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(250000));


          
//etc.


Hope
it helps and any other question please don’t hesitate to let us know.

Regards,