Reputation: 4517
I am using mapbox to show the map and get the route between two markers. Now I am trying to get the screensize fit to two markers. So what is the method to do that in mapbox with android.
Upvotes: 0
Views: 530
Reputation: 3168
in order to accomplish this you need to create a LatLngBounds
and then zoom to that location.
so using the latest SDK version, 4.0.0, you'd achieve this with this code:
LatLngBounds latLngBounds = new LatLngBounds.Builder()
.include(first marker position)
.include(second marker position)
.build();
CameraUpdateFactory.newLatLngBounds(latLngBounds, 10);
You can include as many LatLng
as you'd like by including them within your bounding box. Hope this helps!
Upvotes: 1