Map.getMapPosition at animation end option
This commit is contained in:
parent
85858911fa
commit
71d7b71035
@ -26,7 +26,7 @@ import org.oscim.core.MercatorProjection;
|
||||
*/
|
||||
public class MapPositionActivity extends SimpleMapActivity {
|
||||
|
||||
// Avoid object creation
|
||||
// Reuse MapPosition instance
|
||||
private final MapPosition mapPosition = new MapPosition();
|
||||
|
||||
@Override
|
||||
@ -59,7 +59,7 @@ public class MapPositionActivity extends SimpleMapActivity {
|
||||
mMap.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mapPosition.copy(mMap.animator().getDeltaPosition());
|
||||
mMap.getMapPosition(true, mapPosition);
|
||||
mapPosition.setPosition(latitude, longitude);
|
||||
mMap.animator().animateTo(1000, mapPosition);
|
||||
}
|
||||
|
@ -337,7 +337,11 @@ public class Animator {
|
||||
return mState != ANIM_NONE;
|
||||
}
|
||||
|
||||
public MapPosition getDeltaPosition() {
|
||||
/**
|
||||
* Get the map position at animation end.<br>
|
||||
* Note: valid only with animateTo methods.
|
||||
*/
|
||||
public MapPosition getEndPosition() {
|
||||
return mDeltaPos;
|
||||
}
|
||||
}
|
||||
|
@ -314,11 +314,20 @@ public abstract class Map implements TaskQueue {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current {@link MapPosition}.
|
||||
* Get current {@link MapPosition} or at possible animation end.
|
||||
*
|
||||
* @param animationEnd map position at animation end (valid with Animator.animateTo methods)
|
||||
* @param mapPosition reuse MapPosition instance
|
||||
* @return true when MapPosition was updated (has changed)
|
||||
*/
|
||||
public boolean getMapPosition(MapPosition mapPosition) {
|
||||
public boolean getMapPosition(boolean animationEnd, MapPosition mapPosition) {
|
||||
if (animationEnd) {
|
||||
if (animator().isActive()) {
|
||||
mapPosition.copy(animator().getEndPosition());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ThreadUtils.isMainThread()) {
|
||||
return mViewport.getSyncMapPosition(mapPosition);
|
||||
}
|
||||
@ -326,6 +335,15 @@ public abstract class Map implements TaskQueue {
|
||||
return mViewport.getMapPosition(mapPosition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current {@link MapPosition}.
|
||||
*
|
||||
* @return true when MapPosition was updated (has changed)
|
||||
*/
|
||||
public boolean getMapPosition(MapPosition mapPosition) {
|
||||
return getMapPosition(false, mapPosition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current {@link MapPosition}. Consider using
|
||||
* getViewport.getMapPosition(pos) instead to reuse
|
||||
|
Loading…
x
Reference in New Issue
Block a user