samedi 28 juin 2014

Google Map's doesn't animate camera with new boundries


Vote count:

0




I've got GoogleMap in my android app and what I want to do is to animate camera to be exacly above items in my cluster. It works when the map is first lunched but never again in this session. This is how I want to update my map view:



List<LatLng> pointsList = new ArrayList<LatLng>();

for(MyObject myObject: ObjectsList) {
pointsList.add(new LatLng(myObject.getLatitude(), myObject
.getLongitude()));
}

LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (LatLng latLng : pointsList) {
builder.include(latLng);
}

LatLngBounds bounds = builder.build();
int padding = 100;


mCameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, padding);
mGoogleMap.animateCamera(mCameraUpdate);


I call this whenever I've got new ObjectList to set new boundries. But except first time it never works. I also can show how i put my objects into cluster:



mClusterManager = new ClusterManager<MyClusterItem>(mActivity, mGoogleMap);
mGoogleMap.setOnCameraChangeListener(mClusterManager);
mGoogleMap.setOnMarkerClickListener(mClusterManager);
mClusterManager.setRenderer(new MyClusterRenderer(mActivity, mGoogleMap, mClusterManager));

for (MyObject p : ObjectsList) {
MyClusterItem myClusterItem = new MyClusterItem(p);
mClusterManager.addItem(myClusterItem);

}


Can anybody explain me how to set camera to fit my objects and nothing else every time my objects list has changed?



asked 33 secs ago






Aucun commentaire:

Enregistrer un commentaire