I am developing a GPS application for use in precision agriculture. I need to save the path where the vehicle passed. The drawing must contain the width of the vehicle. I tried using:
gpsLayer.setTrailSymbol(new SimpleLineSymbol(new Color(200, 0, 0, 160), 20));
But the problem is that the polylines are disconnected, therefore remain gaps in the track.
I need to track is equal to an automotive GPS. Does anyone have any idea how to do it?
Thank you
Solved! Go to Solution.
I suggest you create a GraphicsLayer that contains the trail Graphic, and turn off trail in the GPSLayer.
You could add a listener to the GPSWatcher that is passed on the GPSLayer. Whenever the position changes you could update the trail Graphic's geometry.
The trail Graphic could be of type Polyline, and you could append new position to it. Something like this:
private Polyline trail = null;
private int trailGraphicId;
// on position change
if (trail == null) {
trail = new Polyline();
trail.startPath(prevLocationOnMap);
trail.lineTo(currLocationOnMap);
Graphic trailGraphic = new Graphic(trail, symTrail);
trailGraphicId = graphicsLayer.addGraphic(trailGraphic);
} else {
trail.lineTo(currLocationOnMap);
graphicsLayer.updateGraphic(trailGraphicId, trail);
}
Output will now look like
I suggest you create a GraphicsLayer that contains the trail Graphic, and turn off trail in the GPSLayer.
You could add a listener to the GPSWatcher that is passed on the GPSLayer. Whenever the position changes you could update the trail Graphic's geometry.
The trail Graphic could be of type Polyline, and you could append new position to it. Something like this:
private Polyline trail = null;
private int trailGraphicId;
// on position change
if (trail == null) {
trail = new Polyline();
trail.startPath(prevLocationOnMap);
trail.lineTo(currLocationOnMap);
Graphic trailGraphic = new Graphic(trail, symTrail);
trailGraphicId = graphicsLayer.addGraphic(trailGraphic);
} else {
trail.lineTo(currLocationOnMap);
graphicsLayer.updateGraphic(trailGraphicId, trail);
}
Output will now look like
Thanks VGandhi-esristaff,
Your answer solved my problem