Select to view content in your preferred language

Hide a graphic?

735
3
Jump to solution
06-26-2012 12:15 PM
JoshPorter
Occasional Contributor
Is it possible to temporarily remove a graphic from view?  similar in the way that GraphicsLayer.Visiblity = false acts
0 Kudos
1 Solution

Accepted Solutions
JoshPorter
Occasional Contributor
I implemented both in a test project, but it seems easier to extend the Graphic class and add a property much like this one,
  Public Property Visible() As Boolean         Get             Return Me.Geometry IsNot Nothing         End Get         Set(ByVal value As Boolean)             If value Then                 Me.Geometry = mStoredGeometry             Else                 If Me.Geometry IsNot Nothing Then mStoredGeometry = Me.Geometry                 Me.Geometry = Nothing             End If         End Set     End Property


I tried this in a layer using a Flarecluster, and the cluster updated correctly when this property was used. It decremented the count when this property was set to false, and included this Graphic when Visible was set to true. The same is true when maintaining a list of the hidden graphics, but this seems more neat.

View solution in original post

0 Kudos
3 Replies
JoshPorter
Occasional Contributor
Setting Geometry to nothing seems to do the trick, then when i set it back to what it was it is back on the map.
Does this sound like a good plan?
0 Kudos
JoeHershman
MVP Alum
I would just remove the graphic itself (Graphics.Remove) from the Graphics collection, hold onto it and then add it back when needed
Thanks,
-Joe
0 Kudos
JoshPorter
Occasional Contributor
I implemented both in a test project, but it seems easier to extend the Graphic class and add a property much like this one,
  Public Property Visible() As Boolean         Get             Return Me.Geometry IsNot Nothing         End Get         Set(ByVal value As Boolean)             If value Then                 Me.Geometry = mStoredGeometry             Else                 If Me.Geometry IsNot Nothing Then mStoredGeometry = Me.Geometry                 Me.Geometry = Nothing             End If         End Set     End Property


I tried this in a layer using a Flarecluster, and the cluster updated correctly when this property was used. It decremented the count when this property was set to false, and included this Graphic when Visible was set to true. The same is true when maintaining a list of the hidden graphics, but this seems more neat.
0 Kudos