Skip to content

Instantly share code, notes, and snippets.

@mizutori
Created January 11, 2017 08:33
Show Gist options
  • Save mizutori/a80dd26031dcb6f32e76d88caa637d2c to your computer and use it in GitHub Desktop.
Save mizutori/a80dd26031dcb6f32e76d88caa637d2c to your computer and use it in GitHub Desktop.
private void addPolyline() {
ArrayList<Location> locationList = locationService.locationList;
if (locationList.size() == 2) {
Location fromLocation = locationList.get(0);
Location toLocation = locationList.get(1);
LatLng from = new LatLng(((fromLocation.getLatitude())),
((fromLocation.getLongitude())));
LatLng to = new LatLng(((toLocation.getLatitude())),
((toLocation.getLongitude())));
this.runningPathPolyline = map.addPolyline(new PolylineOptions()
.add(from, to)
.width(polylineWidth).color(Color.parseColor("#801B60FE")).geodesic(true));
} else if (locationList.size() > 2) {
Location toLocation = locationList.get(locationList.size() - 1);
LatLng to = new LatLng(((toLocation.getLatitude())),
((toLocation.getLongitude())));
List<LatLng> points = runningPathPolyline.getPoints();
points.add(to);
runningPathPolyline.setPoints(points);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment