优化显示逻辑
This commit is contained in:
@@ -468,7 +468,7 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
return;
|
||||
}
|
||||
|
||||
List< LonLatPoint > newPoints = new ArrayList<>();
|
||||
ArrayList< LonLatPoint > newPoints = new ArrayList<>();
|
||||
for ( int i = 0; i < points.size(); i++ ) {
|
||||
LonLatPoint point = ObjectUtils.fromMogo( points.get( i ) );
|
||||
if ( point == null ) {
|
||||
@@ -480,6 +480,35 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// MarkerTranslateAnimation animation = new MarkerTranslateAnimation( newPoints );
|
||||
// animation.setDuration( duration );
|
||||
// animation.setAnimationListener( new MarkerAnimationListener() {
|
||||
// @Override
|
||||
// public void onAnimationStart( @NotNull Animation animation ) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onAnimationEnd( @NotNull Animation animation ) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// long lastTime = 0L;
|
||||
//
|
||||
// @Override
|
||||
// public void onAnimationRepeat( @NotNull Animation animation ) {
|
||||
// if ( lastTime == 0L ) {
|
||||
// lastTime = System.currentTimeMillis();
|
||||
// return;
|
||||
// }
|
||||
// Logger.d( TAG, "frame cost = %s", System.currentTimeMillis() - lastTime );
|
||||
// lastTime = System.currentTimeMillis();
|
||||
// }
|
||||
// } );
|
||||
// mMarker.setTranslateAnimation( animation );
|
||||
// mMarker.startAnimation();
|
||||
|
||||
mMarker.startSmooth( newPoints, ( int ) duration );
|
||||
// mMarker.addDynamicAnchorPostion( newPoints.get( newPoints.size() - 1 ), ( int ) duration );
|
||||
}
|
||||
|
||||
@@ -17,35 +17,6 @@ public class PointInterpolatorUtil {
|
||||
private static final String TAG = "PointInterpolatorUtil";
|
||||
private static final int DISTANCE_THRESHOLD = 2;
|
||||
|
||||
/**
|
||||
* 在两点之间插值
|
||||
*
|
||||
* @param start
|
||||
* @param end
|
||||
* @param frameInterval
|
||||
* @return
|
||||
*/
|
||||
public static List< MogoLatLng > interpolate( MogoLatLng start, MogoLatLng end, long frameInterval ) {
|
||||
if ( start == null || end == null ) {
|
||||
return null;
|
||||
}
|
||||
long locInterval = end.time - start.time;
|
||||
int interpolateFrame = ( int ) ( locInterval / frameInterval ) - 1;
|
||||
List< MogoLatLng > arrayList = new ArrayList<>();
|
||||
arrayList.add( start );
|
||||
if ( interpolateFrame > 0 ) {
|
||||
double lonStep = ( end.lon - start.lon ) / ( interpolateFrame + 1 );
|
||||
double latStep = ( end.lat - start.lat ) / ( interpolateFrame + 1 );
|
||||
for ( int i = 0; i < interpolateFrame; i++ ) {
|
||||
double lon = start.lon + lonStep * ( i + 1 );
|
||||
double lat = start.lat + latStep * ( i + 1 );
|
||||
arrayList.add( new MogoLatLng( lon, lat ) );
|
||||
}
|
||||
}
|
||||
arrayList.add( end );
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在(x1,y1) (x2,y2)中间插入一些点,使每两个点之间距离<={@link #DISTANCE_THRESHOLD},利用如下公式进行计算
|
||||
* xn = x1 + (x2 - x1)*n/a
|
||||
|
||||
Reference in New Issue
Block a user