I have been using google maps api v2 for around a month. Aside from the other bugs reported in the issue tracker I came across this following odd bug.
java.lang.IllegalStateException: Camera moved during a cancellation which happens inside a CancelableCallback that I use for the animateCamera method. The exception is traced back to the user touch event. I believe this happens because the user is performing an interaction with the map while the onFinish/onCancel is being called now this does not happen often however it is quite irritating.
Is there anyway around this issue? I would appreciate any help you can provide.
Here is the code from inside my callback:
fmMarkerList.getGoogleMap().animateCamera(camUpdate, 350,
new CancelableCallback() {
@Override
public void onFinish() {
openWindowInfoActionBalloon(fmMarkerList,
fmdMarker);
}
@Override
public void onCancel() {
openWindowInfoActionBalloon(fmMarkerList,
fmdMarker);
}
});
And here is the content of openWindowInfoActionBalloon:
private void openWindowInfoActionBalloon(
FriendlyMapMarkerList fmMarkerList, FriendlyMapMarker fmMarker) {
Marker m = fmMarker.getMarker();
m.showInfoWindow();
openActionBalloon(fmMarker, fmMarkerList);
}
And the content of openActionBalloon:
private void openActionBalloon(FriendlyMapMarker marker,
FriendlyMapMarkerList fmMarkerList) {
Projection proj = fmMarkerList.getGoogleMap().getProjection();
Point markerScreenPoint = proj.toScreenLocation(marker.getMarker()
.getPosition());
if (marker.getClass().equals(FriendlyMapPlaceMarker.class)) {
balloonActionsDiscussion.setVisibility(View.INVISIBLE);
balloonActionThought.setVisibility(View.INVISIBLE);
setBalloonDimension(balloonActions, markerScreenPoint);
} else if (marker.getClass().equals(FriendlyMapDiscussionMarker.class)) {
balloonActions.setVisibility(View.INVISIBLE);
balloonActionThought.setVisibility(View.INVISIBLE);
setBalloonDimension(balloonActionsDiscussion, markerScreenPoint);
} else if (marker.getClass().equals(FriendlyMapThoughtMarker.class)) {
balloonActionsDiscussion.setVisibility(View.INVISIBLE);
balloonActions.setVisibility(View.INVISIBLE);
setBalloonDimension(balloonActionThought, markerScreenPoint);
}
And the contents of setBalloonDimension:
private void setBalloonDimension(View ballonActionView,
Point markerScreenPoint) {
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) ballonActionView
.getLayoutParams();
int marginX = markerScreenPoint.x - (ballonActionView.getWidth() / 2);
int marginY = markerScreenPoint.y;
params.setMargins(marginX, marginY, -marginX, -marginY);
params.gravity = Gravity.NO_GRAVITY;
ballonActionView.setLayoutParams(params);
ballonActionView.setVisibility(View.VISIBLE);
}
.
stackoverflow.comm
No comments:
Post a Comment