Tuesday, 10 September 2013

MapController scrollBy() going off the map

MapController scrollBy() going off the map

I am using MapController.scrollyBy() to adjust the screen after I center
on an object since on some devices the centering causes a popup I have to
get cut off. The animateTo() has been working fine for a long time but
when I added scrollBy() it causes the map to jump way off to the edge of
the map. I tried adding a delay as seen below thinking that the scrollBy()
was getting called when the map was still animating but it did not seem to
fix the problem. What could be causing this odd behavoir?
protected void animateTo(int index, GeoPoint center) {
int vertOffset = R.dimen.map_balloon_center_offset;
mc.animateTo(center);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 100ms
}
}, 100);
mc.scrollBy(0, vertOffset);
}

No comments:

Post a Comment