O Google Map Lite Mode moveCamera para limites de latência adiciona preenchimento de mapa indesejado
Quero que a câmera do mapa seja movida para meus LatLngBounds. Então eu adiciono fragmento de mapa ao layoutBaseExpandableListAdapter
égetChildView
eonMapReady
eu voumoveCamera
paraLatLngBounds
@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();
}
Estou calculando limites de acordo comhttp://googlemaps.github.io/android-maps-utils/ e parece funcionar bem como o retângulo adicionado ao mapamoveMapAddBounds
é adicionado em posições válidas, mas a câmera do mapa é movida para a posição quase boa, com a exceção de adicionar um preenchimento aleatório (?) ao mapa (simétrico acima e abaixo do retângulo), como mostra a figura:
Observei que esses preenchimentos são sempre os mesmos para um LatLngBounds específico, mas diferem entre diferentes LatLngBounds.