Way back in 2011 I asked this question, and it was answered. However, that was, I believe, for an older version of MapSuite and now I am having the same problem with version 6. In addition, the question I asked in 2011 was about cancelling the drawing of a shape using TrackOverlay. I have a different situation now because the user drawing is not aborted but continues with a new shape.
Here’s the issue: when using touch displays (as on a tablet) the double-tap does not work well on some devices and thus I need to implement another approach to replace the double-click for ending certain track shape modes. The application is presenting the user with an “end shape” menu option as an alternative. This should trigger a TrackEnded event, after which the shape is stored, the current shape cleared, and then the user is allowed to start a new one by firing “TrackStarted”.
Back in 2011 the answer was to use TrackOverlay.MouseDoubleClick to fire “TrackStarted” to clear out the shapes in the track layer’s internal features. However, under version 6 this doesn’t appear to do the trick, because as soon as I start to draw a new polygon the previous shape is still “stuck” somewhere and the track uses it, even after clearing the features (as shown in the code below.) In addition, after clearing this stuff out and starting to draw again a new “TrackStarted” event does not fire so I can’t detect that the user is drawing a new shape. In other words, the user will draw a polygon, click “End Shape” on a menu, cause the TrackEnded event to fire which stores the shape, then clear things out in the TrackOverlay so that as soon as the user starts again “TrackStarted” is fired for a second shape.
When I use the following logic in TrackOverlay_TrackEnded, things work as expected:
if (winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures.Count == 1)
{
Feature mapNoteFeature = winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures[0];
AddMapNote(mapNoteFeature.GetShape());
}
winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures.Clear();
However, when I use TrackOverlay_MouseDoubleClick to fire the event, the event fires but the shape is still stuck in there and subsequent drawing does not fire TrackStarted.
Any ideas?
Thanks,
Allen