ThinkGeo.com    |     Documentation    |     Premium Support

ZoomLevelsLessThan20 issue

Hi,
I have a scenario, we need to set only zoom level 03 to zoom level 13. rest will be restricted. I tried out your sample(ZoomLevelsLessThan20).
I am restricting map from zoom level 03 to 13, but it’s not going to restrict zoom level 01 and zoom level 02.

Sample
ZoomLevel.zip (2.4 KB)

Please check it and suggest me some code for resolving it,.

Thanks,
Riyaz

Hi Riyaz,

Your zoomlevel set is confused, if you only want to render level 3 to 13, you can just set the style from 3 to 13, I think the code like this should works:

ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(MapPath("~/SampleData/world/cntry02.shp"));
worldLayer.ZoomLevelSet.ZoomLevel03.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green));
worldLayer.ZoomLevelSet.ZoomLevel03.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level13;

If you want to make user cannot zoom to level 1, 2, 14 to 20. I think you can set the custom zoomlevelset, which only leave 3 to 13 levels and remove all the other levels.

Regards,

Ethan

Hi Ethan,
Thanks for your reply. I need same thing like what you said .
Can you please give me code for achieving custom zoomlevelset to restrict zoom level 1, 2, 14 to 20.

Thanks,
Riyaz

Hi Riyaz,

This code should works for you:

                Collection<ZoomLevel> levels = Map1.ZoomLevelSet.GetZoomLevels();

            for (int i = 0; i < 20; i++)
            {
                if (i < 2 || i > 12)
                {
                    continue;
                }

                Map1.ZoomLevelSet.CustomZoomLevels.Add(levels[i]);
        }

Regards,

Ethan

Hi Ethan,
Thanks for your reply. it’s works very well.
Thanks,
Riyaz

Hi Riyaz,

I am glad to hear that’s helpful.

Regards,

Ethan

Hi Ethan,
One more issue, Zoom level restriction is happening to Normal Map(Countries02.shp).
But same thing not happening in Google Maps and OSM.

Please check it and tell me how to restrict it.

Thanks,
Riyaz

Hi Riyaz,

Please choose GoogleMapsLayer instead of GoogleOverlay.

Regards,

Ethan