In the mapsuite FeatureLayer.ZoomLevelSet you have ZoomLevel01, ZoomLevel02, etc… I am going to be including many layers and overlays and I’m trying to reduce the code for the entire program. Is there a way to dynamically call the particular zoom level from a variable.
Example
If I call
AddOverlay(10); // visible starting at zoom level 10
can it execute something like
AddOverlay(ZoomLevel num)
{
layer.ZoomLevelSet.num.ApplyUntilZoomLevel = ApplyUnitlZoomLevel.Level20;
}
or
layer.ZoomLevelSet.ZoomLevel[num].ApplyUntilZoomLevel = ApplyUnitlZoomLevel.Level20;
Layer ZoomLevels of an Overlay
Hi Chad,
If you call the API for example:
myLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
That means the 02 to 20 level will copy all the style from 01 level.
So you can choose start from any zoomlevel and end to any zoomlevel, but the base zoomlevel should contains your target style.
For example:
myLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level04;
myLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.Capital1;
myLayer.ZoomLevelSet.ZoomLevel05.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level11;
myLayer.ZoomLevelSet.ZoomLevel05.DefaultPointStyle = PointStyles.City1;
myLayer.ZoomLevelSet.ZoomLevel12.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
myLayer.ZoomLevelSet.ZoomLevel12.DefaultPointStyle = PointStyles.City7
So I think you can just write a custom function for implement that.
Regards,
Don
Thanks Don, but I was hoping to be able to call the start level dynamically from a variable. I’m basically combining multiple overlay creation functions into one function. Problem is, each overlay has a labels layer that will need to be seen at different levels from other overlay label layers. I guess I could just write a giant switch statement to handle each zoom level but that seems excessive if I could just call something like myLayer.ZoomLevelSet.x.DefaultPointStyle… where x could be ZoomLevel05, or ZoomLevel16, etc.
Hi Chad,
I think you can implement that like this:
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"…\Data\USStates.shp");
GetZoomLevel(5, worldLayer.ZoomLevelSet).DefaultAreaStyle = AreaStyles.Country1;
GetZoomLevel(5, worldLayer.ZoomLevelSet).ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
private ZoomLevel GetZoomLevel(int number, ZoomLevelSet set)
{
System.Collections.ObjectModel.Collection<ZoomLevel> zoomlevels = set.GetZoomLevels();
if (number > 0 && number <= zoomlevels.Count)
{
return zoomlevels[number - 1];
}
return zoomlevels[0];
}
I’ll try it out. Thanks Don.
Hi Chad,
Did it work with you?
Any questions please let us know.
Regards,
Peter
Just implemented it and YES it does work. This is exactly what I needed. Thank you Don and Peter.
Hi Chad,
You’re welcome. Very glad to hear it works.
Regards,
Peter