Hi,
I’m normally using CustomStyles collection to render my layers.
Usually the setup is finished with setting the single target level’s ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
CustomStyles thus contains a mix of PointStyle, LineStyle, AreaStyle, and TextStyle elements.
But say I want to (extreme case, for the purpose of the question) render points on levels 5 - 20, lines on levels 7 - 18, areas on levels 2 - 15, and text labels on levels 6 - 13, how do I go about that ?
What levels should get what customstyle elements, and what ? And what styles apply to level 11 in the above setup ?
The property ApplyUntilZoomLevel is set on the level itself, so if I repeatedly set it, it will be overwritten, right ?
And what exactly happens with the intermediate levels, when I set the ApplyUntilZoomLevel value on a level, and e.g. set it to ApplyUntilZoomLevel.Level20 ?
If I wanted to enact my extreme setup, would I need to copy my style objects onto every relevant level, and set them all to ApplyUntilZoomLevel = ApplyUntilZoomLevel.None ??
Cheers
Understanding how ApplyUntilZoomLevel works?
Hi Lars,
Basically, the ApplyUnitlZoomLevel property is used to save your codes by copying the current zoomlevel style setting to the target zoomlevel, which you are specified for this property. For instance:
osm_baseland_polygon.ZoomLevelSet.ZoomLevel11.CustomStyles.Add(GetBaseLandAreaStyle());
osm_baseland_polygon.ZoomLevelSet.ZoomLevel11.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
From above code, the first line means we specify an custom area style for the zoomlevel 11 and the second line means we want to specify all the zoomlevels from zoomlevel 11 to 20 to use this area style when drawing. With this property, then we don’t have to specify the style one by one from 11 to 12.
Based on your case: “points on levels 5 - 20, lines on levels 7 - 18, areas on levels 2 - 15, and text labels on levels 6 - 13”. I think there are two options:
- Defining 4 types layers(point,line,area,label) and specify the styles for difference zoomlevel, then add them into one layeroverlay. Some codes like :
FeatureLayer pointLayer = new ShapeFileFeatureLayer();
pointLayer.ZoomLevelSet.ZoomLevel5.CustomStyles.Add(pointstyle);
pointLayer.ZoomLevelSet.ZoomLevel5.ApplyUnitlZoomLevel = ApplyUnitlZoomLevel.Level20;
FeatureLayer lineLayer = new ShapeFileFeatureLayer();
pointLayer.ZoomLevelSet.ZoomLevel7.CustomStyles.Add(linestyle);
pointLayer.ZoomLevelSet.ZoomLevel7.ApplyUnitlZoomLevel = ApplyUnitlZoomLevel.Level18;
…
layerOvelay.Layers.Add(pointLayer);
layerOvelay.Layers.Add(lineLayer);
layerOvelay.Layers.Add(areaLayer);
layerOvelay.Layers.Add(labelLayer);
The other way is specifying kinds of custom styles for each zoomlevel and we don’t need the ApplyUnitlZoomLevel property, this will needs more codes but more exact to control for your case. -
FeatureLayer layer = new ShapeFileFeatureLayer();
layer.zoomlevelset.zoomlevel02.customstyle.add(areastyle);
layer.zoomlevelset.zoomlevel02.ApplyUnitlZoomlevel = ApplyUntilZoomLevel05; // here we can use the ApplyUnitZoomLevel is because this range zoomlevel has the same styles.
layer.zoomlevelset.zoomlevel05.customstyle.add(areastyle);
layer.zoomlevelset.zoomlevel05.customstyle.add(pointtyle);
layer.zoomlevelset.zoomlevel06.customstyle.add(areastyle);
layer.zoomlevelset.zoomlevel06.customstyle.add(pointtyle);
layer.zoomlevelset.zoomlevel06.customstyle.add(texttyle);
layer.zoomlevelset.zoomlevel07.customstyle.add(areastyle);
layer.zoomlevelset.zoomlevel07.customstyle.add(pointtyle);
layer.zoomlevelset.zoomlevel07.customstyle.add(texttyle);
layer.zoomlevelset.zoomlevel07.customstyle.add(linetyle);
…
As for what happens when we set the ApplyUnitZoomlevel value, actually, it won’t change anything immediately but it only affects when drawing.
Here are some articles about the ZoomLevel, Please check it. wiki.thinkgeo.com/wiki/Map_S…oom_Levels
Please let us know if you have any questions on the above.
Thanks,
Troy
Hi Troy,
Thanks for the explanation, and the link.
I can see that I wasn’t entirely clear about my problem, because points, lines and areas are naturally split across multiple layers.
However, I have at least two style on each layer, one is the geometric style, and one is the label textstyle. They often have different zoom level settings.
So my question is, what styles are active on layer 18 in the following scenario:
myLayer.ZoomLevelSet.ZoomLevel10.CustomStyles.Add(
New
PointStyle(…))
myLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
myLayer.ZoomLevelSet.ZoomLevel15.CustomStyles.Add(
New
TextStyle(…))
myLayer.ZoomLevelSet.ZoomLevel15.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
My assumption is that the PointStyle references on levels 16-20 to level 10 are overwritten by the latter “ApplyUntilZoomLevel”.
Is this assumption correct ?
If I want complete freedom, should and can I then physically add the relevant style objects into each target level’s CustomStyles, and set each level’s
.ApplyUntilZoomLevel = ApplyUntilZoomLevel.None ?
Cheers
Hi Lars,
For CustomStyles, no, the point style won’t be overwritten by textstyle from zoomlevel 15 to 20. In your codes, the zoomlevels from 15 to 20 will include both pointstyle and text style. Actually, all the styles defined in customStyle won’t be overwriten even those styles are defined in difference Zoomlevel.
Besides, we don’t have to set the ApplyUntilZoomLevel as None as None is defined by default.
Thanks,
Troy