Reputation: 337
I try to plot two location using this tutorial(http://wptrafficanalyzer.in/blog/driving-route-from-my-location-to-destination-in-google-maps-android-api-v2/) . But it work . Problem is it not zoom plot path.
1) why this path not zoom ?
2) how to zoom the path?
Upvotes: 1
Views: 4431
Reputation: 2947
You can use Latlngbounds to zoom your path using following code
Builder boundsBuilder = new LatLngBounds.Builder();
boundsBuilder.include(currentLocationLatLng);
boundsBuilder.include(targetLocationLatLng);
LatLngBounds bounds = boundsBuilder.build();
googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 3));
or if you want to animate this too
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
googleMap.moveCamera(cu);
googleMap.animateCamera(cu);
Upvotes: 3