1

what is the better way for zoom the map to show all the route after getting it?

I tried to do it with my Origin and Destination, but not working well if the route go over or down those.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
JFDionne
  • 125
  • 7

1 Answers1

0

You will need to create a bounding box for your camera to animate to.

LatLngBounds latLngBounds = new LatLngBounds.Builder()
                .include((new LatLng(origin.latitude() , origin.longitude())))
                .include((new LatLng(dest.latitude(), dest.longitude())))
                .build();

map.animateCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 250));
Jk Jensen
  • 339
  • 2
  • 4
  • 16