El modo Google Map Lite moveCamera a los límites de la longitud agrega un relleno de mapa no deseado
Quiero que la cámara del mapa se mueva a mis LatLngBounds. Entonces agrego un fragmento de mapa al diseño enBaseExpandableListAdapter
'sgetChildView
yonMapReady
EnfermomoveCamera
aLatLngBounds
@Override
public View getChildView(final int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
convertView = inflater.inflate(R.layout.event_child, parent, false);
GoogleMapOptions options = new GoogleMapOptions();
options.liteMode(true)
.compassEnabled(false)
.mapToolbarEnabled(false)
.rotateGesturesEnabled(false)
.tiltGesturesEnabled(false)
.scrollGesturesEnabled(false)
.zoomControlsEnabled(false)
.zoomGesturesEnabled(false);
SupportMapFragment mapFragment = SupportMapFragment.newInstance(options);
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.add(R.id.event_fragment_map, mapFragment, "event_fragment_map").commit();
mapFragment.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
mGoogleMap = googleMap;
moveMapAddBounds();
}
});
//...
}
private void moveMapAddBounds(){
mGoogleMap.addPolygon(new PolygonOptions().add(getLatLngBounds().southwest)
.add(new LatLng(getLatLngBounds().northeast.latitude, getLatLngBounds().southwest.longitude))
.add(getLatLngBounds().northeast)
.add(new LatLng(getLatLngBounds().southwest.latitude, getLatLngBounds().northeast.longitude))
);
mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(getLatLngBounds(), 0));
}
public LatLngBounds getLatLngBounds() {
//random fake latlng and distance
LatLng from = new LatLng(51.1113564, 17.0041787);
double distance = 1717.906494140625;
return new LatLngBounds.Builder().
include(SphericalUtil.computeOffset(from, distance, 0)).
include(SphericalUtil.computeOffset(from, distance, 90)).
include(SphericalUtil.computeOffset(from, distance, 180)).
include(SphericalUtil.computeOffset(from, distance, 270)).build();
}
Estoy calculando límites de acuerdo ahttp://googlemaps.github.io/android-maps-utils/ y parece funcionar bien ya que el rectángulo agregado al mapa enmoveMapAddBounds
se agrega en posiciones válidas, pero la cámara del mapa se mueve a una posición casi buena con la excepción de que agrega un relleno aleatorio (?) al mapa (simétrico arriba y debajo del rectángulo) como se ve en la imagen:
He observado que esos rellenos son siempre los mismos para un LatLngBounds en particular, pero difieren entre los diferentes LatLngBounds.