Skip to content

Instantly share code, notes, and snippets.

@pratamawijaya
Created February 20, 2015 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pratamawijaya/9268aa5edd46d29d304c to your computer and use it in GitHub Desktop.
Save pratamawijaya/9268aa5edd46d29d304c to your computer and use it in GitHub Desktop.
private void drawDirectionToMap(List<LatLng> latLngList) {
PolylineOptions line = new PolylineOptions().width(3).color(Color.BLUE);
for (int i = 0; i < latLngList.size(); i++) {
line.add(latLngList.get(i));
}
mMap.addPolyline(line);
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latLngList.get(0).latitude, latLngList.get(0).longitude), 14));
// add marker diawal
mMap.addMarker(new MarkerOptions()
.position(new LatLng(latLngList.get(0).latitude, latLngList.get(0).longitude))
.title("starting point")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_marker))
);
// add marker di akhir
int index = latLngList.size() - 1;
mMap.addMarker(new MarkerOptions()
.position(new LatLng(latLngList.get(index).latitude, latLngList.get(index).longitude))
.title("end point")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_marker))
);
Toast.makeText(this, "Jalur berhasil digambar kak, hati2 dijalan pelan2 saja,,, ", Toast.LENGTH_SHORT).show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment