Joe Joe - 1 year ago 104
Android Question

How to show both markers on Google Maps?

I have a maps activity that displays an origin and a destination location (Point A and Point B). However, when the origin and destination locations are inputted. Only the Origin is displayed initially. You would have to zoom out to see the destination on the map. How can I show both markers at the same time?

I would like it to fill the entire fragment

Answer Source

You need to set up a LatLng bounds to fit all of your points (in this case, just two) within the Map's camera. Take this code for example:

final LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(markerA.getPosition()); // this is a LatLng value
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(, 100));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download