MapSuite Team,
I’ve discovered that the Layer IsVisible Property is set to True even though a layer is not actually visible.
When layer visibility is controlled by styles the IsVisible Property is always True even though the layer is not rendered when there are no styles for any given ZoomLevel.
Is there any other property that indicates whether or not any given layer is actually visible? Or do I have to implement my own method that determines if a layer is actually visible by taking into account the IsVisible Property and whether there are styles defined for the current ZoomLevel?
Thanks,
Dennis
Layer IsVisible Property
Hi Dennis,
The IsVisible property of layer is true by default even though there are no any styles apply to it.
There is no property that indicates whether or not any layer is actually visible. But you can do it by your own method and there are two properties to determine whether to draw a layer or not. The one is the IsVisible property of layer and the other one is IsActive property of ZoomLevel(It’s still true by default). The layer will not be rendered if one of them is false.
Hope it’s helped.
Thanks,
Peter
Peter,
I’ve tried changing the ZoomLevel.IsActive property to false and then the map display draws the typical big x all in a light red. So application code changing that property not a good idea.
How does the WpfDesktopEdition drawing methods know whether to draw a layer? And it seems like all the ZoomLevel.IsActive properties are set to true even if there are no styles for any particular ZoomLevel.
It would appear that I have to implement my own property that indicates whether a layer is currently visible which would be based on whether there are any styles defined for the scale.
Thanks,
Dennis
Hi Dennis,
As I described as before the ZoomLevel.IsAcive property is true by default.
How does the WpfDesktopEdition drawing methods know whether to draw a layer?
The following simplified processes is how WpfDesktopEdition draw.
1. Draw the overlay if it’s visible.
2. Draw the visible layers in the LayerOverlay.Layers.
3. Use current ZoomLevel to draw the layers if the zoomlevel is active.
Hope it’s helped.
Thanks,
Peter
Peter,
Are you saying that is ZoomLevel.IsActive = False the layer will not be drawn?
Is the application permitted to change the ZoomLevel.IsActive Property to True or False?
When does WpfDesktopEdition set the ZoomLevel.IsActive Property to True or False? Does it ever set it to False?
Thanks,
Dennis
Hi Dennis,
Yes, you are right. The layer will not be drawn if its ZoomLevel is not active. And you can change the ZoomLevel.IsActive in application, but usually we prefer to change the Layer.IsVisible to determine if the layer should be drawn.
Thanks,
Peter
Peter,
I agree with you in that I would prefer not to be changing the ZoomLevel.IsActive Property.
In the past I was changing the Layer.IsVisible Property during the ScaleChanging Event. I’ve have since changed that among other things because I was getting Drawing/Drawn Exceptions and thought that these where partly due to changing Layer.IsVisible.
Do you feel it is safe to set Layer.IsVisible either True or False within the ScaleChanging Event? I actually prefer to control layer visibility at the application level as opposed to being controlled via ZoomLevel Styles as it gives me more flexibility as to when a layer is visible or not.
Thanks,
Dennis
Hi Dennis,
We don’t change the [Layer.IsVisible] during Draw the layers internally, so it’s okay to changing it within the CurrentScaleChanging Event.
Cloud you please attach the code where throws the exceptions in the ScaleChanging Event or the exception message here?
Do you mean you want to control the layers will only be visible from one low level to one high level? If so, maybe the ZoomLevel.ApplyUnitlZoomLevel property is useful. The code just like the following:
layer.ZoomLevelSet.ZoomLevelxx.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Levelxx;
Thanks,
Peter
Peter,
Thanks for the clarification on setting Layer.IsVisible within the CurrentScaleChanging Event. This will make it easier to achieve my goal.
I’m actually working with your colleague Don concerning the Drawing/Drawn Exceptions.
I do make extensive use of the ApplyUntilZoomLevel Property. My application provides several methods whereby any given layer is Visible or InVisible. First, for some layers visibility is controlled manually by each user, upon startup these layers are InVisible, if the user wants them to be displayed they must manually make them visible. Second, some layers are made Visible/InVisible automatically based on current zoom level, for any of these the user may manually set to InVisible and they stay InVisible until the user makes them visible again. Even if a layer is automatically made InVisible the user may override that and make it Visible.
Thanks for your help on this.
Dennis
Dennis,
The samples attached here is shows how to control the visibility of layer by IsVisible and ZoomLevel.
Hope it’s helpful.
Thanks,
Peter
LayerVisibleSample.zip (1.5 MB)