I'm playing around with the TrackMode types in the TrackOverlay and I run into a problem with shape removal.
If I switch from TrackMode.Polygon to TrackMode.None, and then eventually back to TrackMode.Polygon, I run into a problem where the original polygon is still visible. This happens in the case that the user didn't double click in the map to complete the first Polygon.
I've tried doing TrackOverlay.TrackShapeLayer.InternalFeatures.Clear(), and that didn't seem to work.
How do I make the TrackOverlay start fresh when I switch back to Polygon from None?
Also, is there an exposed function for what happens when the user double-clicks during polygon creation? It would be nice if I could add a context menu option for ending the Polygon creation.
Hi Greg, I think I can help with this. I allow a user to start drawing a polygon, but if they want to cancel out in the middle without it being complete, I capture a keydown event on the map. If they hit escape, I have it clear all the features from the track layer and then I call
and then I refresh the map. In my code that handles the track0ended event, I have a check to make sure that there is actually a feature on the trackShapes layer.
Just to be complete, I also allow the user to hit the enter key instead of double clicking to finalize the tracking. In that case, I just have the line of code above.
I am glad we could help you on this. I just let you know in case you are interested, we have a new project in the Code Community also related to tracking polygons and rectangles, Editing Rectangles.
I am having a similar problem as what's described in the OP. I have captured the Esc key and am able to clear the poly from screen, but when the user clicks the poly button in our toolbar again, the poly they were drawing shows up again. basically picking up from where they left off.
Here is the code that I'm executing to accomplish behavior:
I did implement the code inside the example "Canceling TrackOverlay" and what that seemed to accomplish was ending the drawing, causing my OnTrackOverlayTrackEnded event to fire. Basically what i would expect to happen when pressing the enter key.
So the question is, how can i ensure that when the user clicks the poly button in our toolbar, that a new poly is started?