Skip to content Skip to sidebar Skip to footer

Cameraupdatefactory.newlatlngbounds Is Not Workinf All The Time

I'm having some problema to move camera on android google maps. I have that function: protected void centralizeMapToBounds(final LatLng southwest, final LatLng northeast, final Lat

Solution 1:

Not sure what you want to achieve with the code in your question. It's a bit messy.

If you want to show area containing 3 LatLngs, you are better of using

LatLngBounds bounds = LatLngBounds.builder().include(latLng1).include(northeast).include(taxi).build();
map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding));

This would replace all your ifs and try-catches with a few lines.

Btw. You shouldn't be doing try-catches in your code. A programming error is not something you catch and try something different, but change the code instead.


Solution 2:

I got the solution putting all with 4 decimal digits.

String.format("%.4f", d)

Post a Comment for "Cameraupdatefactory.newlatlngbounds Is Not Workinf All The Time"