nickcam/DirectionalLineSymbol

DirectionalLineSymbol cannot hide when the graphic hide

Closed this issue · 1 comments

When i invoke the hide method of the graphic,DirectionalLineSymbol cannot hide.

Hi @MagicWang,

Yeah that's true...there's no event I could find that relates to the hiding of a graphic, so there's no place to destroy the directional symbols on hide.

Showing it again would be easy, as a graphics layer "graphic-draw" event could be used, but unfortunately hidden graphics don't trigger that event so that's no good.

The easy way to do it is to just remove and re-add the graphic from the layer to show and hide. It means you need to maintain a reference to the graphic in a variable though.

For example:

var graphic = graphicsLayer.graphics[0];
graphicsLayer.remove(graphic); //to hide
graphicsLayer.add(graphic); // to show again

If that doesn't suit you, could probably do something with the layers update-start or update-end events, but haven't really investigated them as it means adding a new event to each layer, and you'd probably have to call graphicsLayer.redraw() after every hide and show call anyway.

So figure just removing and adding is simpler. Will that work for you?