Hi there,
I am using the Google Location Services API on Android to periodically save a latitude/longitude they were at. I am trying to create a polygon around these points to create a route of where they have been. I want the route to take into the location accuracy for each of the points, so instead of a line it will look like a snake that expands and shrinks as the GPS accuracy changes.
This is something close to what I want, however, it is a polyline with a standard thickness throughout.
At a later time, I want to be able to validate if the user has returned inside this polygon.
Thanks in advance for any help!
Ronan
What I have tried:
I am using location.getAccuracy() to determine the accuracy of the polled location and my aim is to include a radius around the point based on this. This accuracy is then used to create a diamond of four points. Although this accurately shows for one location, when multiple locations are added, the polygon looks very wrong with points intersecting each other.
I thought about drawing one big polygon around all the locations but this wouldn't work as I would end up with an area instead of a route, the polygon wouldn't show accurately where the user actually travelled.
How I am generating the polygon points at the moment:
List<LatLng> points = new ArrayList<LatLng>();
for (Location location : locations) {
float accuracy = location.getAccuracy();
System.out.println(accuracy);
points.add(SphericalUtil.computeOffset(new LatLng(location.getLatitude(), location.getLongitude()), accuracy, 0));
points.add(SphericalUtil.computeOffset(new LatLng(location.getLatitude(), location.getLongitude()), accuracy, 90));
points.add(SphericalUtil.computeOffset(new LatLng(location.getLatitude(), location.getLongitude()), accuracy, 180));
points.add(SphericalUtil.computeOffset(new LatLng(location.getLatitude(), location.getLongitude()), accuracy, 270));
}
How I draw the polygon onto the map:
PolygonOptions polygonOptions = new PolygonOptions();
for (LatLng latLng : route.getPolygonPoints()) {
polygonOptions.add(latLng);
}
mMap.clear();
Polygon polygon = mMap.addPolygon(polygonOptions.strokeColor(Color.argb(255, 49, 101, 187)).fillColor(Color.argb(100, 49, 101, 187)));