opt
This commit is contained in:
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.CoordinatesTransformer;
|
||||
import com.mogo.map.IMogoMapApiBuilder;
|
||||
import com.mogo.map.IMogoMapView;
|
||||
import com.mogo.map.MapApiPath;
|
||||
@@ -114,6 +115,11 @@ class AMapApiBuilder implements IMogoMapApiBuilder {
|
||||
return IconTypeUtils.getResIdByIconType( context, iconType );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CoordinatesTransformer getCoordinatesTransformer() {
|
||||
return AMapCoordinatesTransformer.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
Logger.d( TAG, "init." );
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.mogo.map.impl.amap;
|
||||
|
||||
import com.mogo.map.CoordinatesTransformer;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/17
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class AMapCoordinatesTransformer implements CoordinatesTransformer {
|
||||
|
||||
private AMapCoordinatesTransformer() {
|
||||
// private constructor
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
private static final AMapCoordinatesTransformer INSTANCE = new AMapCoordinatesTransformer();
|
||||
}
|
||||
|
||||
public static AMapCoordinatesTransformer getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] transform( double lat, double lon ) {
|
||||
double[] coor = new double[2];
|
||||
coor[0] = lat;
|
||||
coor[1] = lon;
|
||||
return coor;
|
||||
// return new double[]{lat, lon};
|
||||
// return CoordinateUtils.transformGcj02toWgs84( lat, lon );
|
||||
}
|
||||
}
|
||||
@@ -525,6 +525,11 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
mMovingPointOverlay.startSmoothMove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startSmoothInMs( List< MogoLatLng > points, long duration ) {
|
||||
startSmooth( points, ( ( int ) ( duration / 1000 ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInfoWindowShowing() {
|
||||
if ( mMarker == null ) {
|
||||
|
||||
@@ -192,7 +192,7 @@ public class ObjectUtils {
|
||||
if ( latLng == null ) {
|
||||
return null;
|
||||
}
|
||||
return new LatLng( latLng.lat, latLng.lng );
|
||||
return new LatLng( latLng.lat, latLng.lon );
|
||||
}
|
||||
|
||||
public static MogoLatLng fromAMap( LatLonPoint point ) {
|
||||
|
||||
@@ -67,7 +67,7 @@ dependencies {
|
||||
implementation project(':foudations:mogo-commons')
|
||||
}
|
||||
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-7.1.5'
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-7.1.8'
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.map.impl.custom;
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.CoordinatesTransformer;
|
||||
import com.mogo.map.IMogoMapApiBuilder;
|
||||
import com.mogo.map.IMogoMapView;
|
||||
import com.mogo.map.MapApiPath;
|
||||
@@ -116,6 +117,11 @@ class CustomMapApiBuilder implements IMogoMapApiBuilder {
|
||||
return IconTypeUtils.getResIdByIconType( context, iconType );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CoordinatesTransformer getCoordinatesTransformer() {
|
||||
return CustomMapCoordinatesTransformer.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
Logger.d( TAG, "init" );
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.mogo.map.impl.custom;
|
||||
|
||||
import com.mogo.map.CoordinatesTransformer;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/17
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class CustomMapCoordinatesTransformer implements CoordinatesTransformer {
|
||||
|
||||
private CustomMapCoordinatesTransformer() {
|
||||
// private constructor
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
private static final CustomMapCoordinatesTransformer INSTANCE = new CustomMapCoordinatesTransformer();
|
||||
}
|
||||
|
||||
public static CustomMapCoordinatesTransformer getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] transform( double lat, double lon ) {
|
||||
double[] coor = new double[2];
|
||||
coor[0] = lat;
|
||||
coor[1] = lon;
|
||||
return coor;
|
||||
}
|
||||
}
|
||||
@@ -52,35 +52,36 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
private MogoMarkerOptions mMogoMarkerOptions;
|
||||
private String mOwner;
|
||||
|
||||
public AMapMarkerWrapper(Marker marker, MogoMarkerOptions mogoMarkerOptions) {
|
||||
public AMapMarkerWrapper( Marker marker, MogoMarkerOptions mogoMarkerOptions ) {
|
||||
this.mMarker = marker;
|
||||
if (marker != null) {
|
||||
if ( marker != null ) {
|
||||
// 设置自研 marker 的object对象为 IMogoMarker 实例。!!!!
|
||||
marker.setMObject(this);
|
||||
MarkerWrapperClickHelper.getInstance().setMogoMarkerMap(marker.getId(),this);
|
||||
marker.setMObject( this );
|
||||
MarkerWrapperClickHelper.getInstance().setMogoMarkerMap( marker.getId(), this );
|
||||
}
|
||||
setObject(mogoMarkerOptions.getObject());
|
||||
setObject( mogoMarkerOptions.getObject() );
|
||||
this.mMogoMarkerOptions = mogoMarkerOptions;
|
||||
mMogoMarkerOptions.addObserver(this);
|
||||
mMogoMarkerOptions.addObserver( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Observable o, Object arg) {
|
||||
if (isDestroyed()) {
|
||||
public void update( Observable o, Object arg ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
setMarkerOptions(mMogoMarkerOptions);
|
||||
setMarkerOptions( mMogoMarkerOptions );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (mMogoMarkerOptions != null) {
|
||||
if ( mMogoMarkerOptions != null ) {
|
||||
mMogoMarkerOptions.deleteObservers();
|
||||
mMogoMarkerOptions = null;
|
||||
}
|
||||
if (mMarker != null) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.remove();
|
||||
mMarker.setMObject(null);
|
||||
mMarker.setMObject( null );
|
||||
mMarker.setOnInfoWindowClickListener( null );
|
||||
mMarker = null;
|
||||
}
|
||||
mMogoInfoWindowAdapter = null;
|
||||
@@ -96,45 +97,45 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
|
||||
@Override
|
||||
public void hideInfoWindow() {
|
||||
if (mMarker != null) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.hideInfoWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(float alpha) {
|
||||
if (mMarker != null) {
|
||||
mMarker.setAlpha(alpha);
|
||||
public void setAlpha( float alpha ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setAlpha( alpha );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnchor(float anchorU, float anchorV) {
|
||||
if (mMarker != null) {
|
||||
mMarker.setAnchor(anchorU, anchorV);
|
||||
public void setAnchor( float anchorU, float anchorV ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setAnchor( anchorU, anchorV );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDraggable(boolean paramBoolean) {
|
||||
public void setDraggable( boolean paramBoolean ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setDraggable( paramBoolean );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIcon(Bitmap icon) {
|
||||
if (icon == null || icon.isRecycled()) {
|
||||
public void setIcon( Bitmap icon ) {
|
||||
if ( icon == null || icon.isRecycled() ) {
|
||||
return;
|
||||
}
|
||||
if (mMarker != null) {
|
||||
mMarker.setIcon(icon);
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setIcon( icon );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIcons(ArrayList<Bitmap> icons) {
|
||||
if (icons == null || icons.isEmpty()) {
|
||||
public void setIcons( ArrayList< Bitmap > icons ) {
|
||||
if ( icons == null || icons.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
// ArrayList<BitmapDescriptor> descriptors = new ArrayList<>();
|
||||
@@ -153,9 +154,9 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInfoWindowEnable(boolean enabled) {
|
||||
if (mMarker != null) {
|
||||
if (enabled) {
|
||||
public void setInfoWindowEnable( boolean enabled ) {
|
||||
if ( mMarker != null ) {
|
||||
if ( enabled ) {
|
||||
mMarker.showInfoWindow();
|
||||
} else {
|
||||
mMarker.hideInfoWindow();
|
||||
@@ -164,20 +165,20 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarkerOptions(MogoMarkerOptions opt) {
|
||||
public void setMarkerOptions( MogoMarkerOptions opt ) {
|
||||
|
||||
final MarkerOptions options = ObjectUtils.fromMogo(opt);
|
||||
if (options == null) {
|
||||
final MarkerOptions options = ObjectUtils.fromMogo( opt );
|
||||
if ( options == null ) {
|
||||
return;
|
||||
}
|
||||
if (mMarker != null) {
|
||||
mMarker.setMarkerOptions(options);
|
||||
setObject(opt.getObject());
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setMarkerOptions( options );
|
||||
setObject( opt.getObject() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObject(Object object) {
|
||||
public void setObject( Object object ) {
|
||||
mObject = object;
|
||||
}
|
||||
|
||||
@@ -187,89 +188,89 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPeriod(int period) {
|
||||
if (mMarker != null) {
|
||||
mMarker.setPeriod(period);
|
||||
public void setPeriod( int period ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setPeriod( period );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(double lat, double lng) {
|
||||
if (mMarker != null) {
|
||||
mMarker.setPosition(new LonLatPoint(lng,lat));
|
||||
public void setPosition( double lat, double lng ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setPosition( new LonLatPoint( lng, lat ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getPosition() {
|
||||
if (mMarker != null) {
|
||||
if ( mMarker != null ) {
|
||||
final LonLatPoint latLng = mMarker.getPosition();
|
||||
return ObjectUtils.fromAMap(latLng);
|
||||
return ObjectUtils.fromAMap( latLng );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotateAngle(float rotate) {
|
||||
if (mMarker != null) {
|
||||
mMarker.setRotateAngle(rotate);
|
||||
public void setRotateAngle( float rotate ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setRotateAngle( rotate );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSnippet(String snippet) {
|
||||
if (mMarker != null) {
|
||||
mMarker.setSnippet(snippet);
|
||||
public void setSnippet( String snippet ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setSnippet( snippet );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitle(String title) {
|
||||
if (mMarker != null) {
|
||||
mMarker.setTitle(title);
|
||||
public void setTitle( String title ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setTitle( title );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToTop() {
|
||||
if (mMarker != null) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setToTop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean visible) {
|
||||
if (mMarker != null) {
|
||||
mMarker.setVisible(visible);
|
||||
public void setVisible( boolean visible ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setVisible( visible );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZIndex(int zIndex) {
|
||||
if (mMarker != null) {
|
||||
mMarker.setZIndex(zIndex);
|
||||
public void setZIndex( int zIndex ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setZIndex( zIndex );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showInfoWindow() {
|
||||
if (mMarker != null) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.showInfoWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnMarkerClickListener(IMogoMarkerClickListener listener) {
|
||||
public void setOnMarkerClickListener( IMogoMarkerClickListener listener ) {
|
||||
mMogoMarkerClickListener = listener;
|
||||
if(mMarker != null){
|
||||
mMarker.setOnMarkClickListener(new OnMarkClickListener() {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setOnMarkClickListener( new OnMarkClickListener() {
|
||||
@Override
|
||||
public void onMarkClick(@NotNull Marker marker) {
|
||||
if(mMogoMarkerClickListener!= null){
|
||||
mMogoMarkerClickListener.onMarkerClicked(AMapMarkerWrapper.this);
|
||||
}
|
||||
public void onMarkClick( @NotNull Marker marker ) {
|
||||
if ( mMogoMarkerClickListener != null ) {
|
||||
mMogoMarkerClickListener.onMarkerClicked( AMapMarkerWrapper.this );
|
||||
}
|
||||
}
|
||||
});
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +280,7 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInfoWindowAdapter(IMogoInfoWindowAdapter adapter) {
|
||||
public void setInfoWindowAdapter( IMogoInfoWindowAdapter adapter ) {
|
||||
mMogoInfoWindowAdapter = adapter;
|
||||
}
|
||||
|
||||
@@ -289,11 +290,11 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarkerIconView(IMogoMarkerIconViewCreator creator) {
|
||||
if (creator != null) {
|
||||
View iconView = creator.createView(this);
|
||||
if (iconView != null) {
|
||||
mMarker.setIcon(iconView);
|
||||
public void setMarkerIconView( IMogoMarkerIconViewCreator creator ) {
|
||||
if ( creator != null ) {
|
||||
View iconView = creator.createView( this );
|
||||
if ( iconView != null ) {
|
||||
mMarker.setIcon( iconView );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,25 +305,25 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwner(String mOwner) {
|
||||
public void setOwner( String mOwner ) {
|
||||
this.mOwner = mOwner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwner() {
|
||||
if (mOwner != null) {
|
||||
if ( mOwner != null ) {
|
||||
return mOwner;
|
||||
}
|
||||
if (mMogoMarkerOptions != null) {
|
||||
if ( mMogoMarkerOptions != null ) {
|
||||
return mMogoMarkerOptions.getOwner();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPositionByPixels(Point position) {
|
||||
if (mMarker != null) {
|
||||
mMarker.setPosition(MapTools.INSTANCE.fromScreenLocation(position));
|
||||
public void setPositionByPixels( Point position ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setPosition( MapTools.INSTANCE.fromScreenLocation( position ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,11 +337,11 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startScaleAnimation(float fromX, float toX, float fromY, float toY, int duration, Interpolator interpolator) {
|
||||
if (isDestroyed()) {
|
||||
public void startScaleAnimation( float fromX, float toX, float fromY, float toY, int duration, Interpolator interpolator ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
startScaleAnimation(fromX, toX, fromY, toY, duration, interpolator,null);
|
||||
startScaleAnimation( fromX, toX, fromY, toY, duration, interpolator, null );
|
||||
// ScaleAnimation animationScale = new ScaleAnimation(fromX, toX, fromY, toY);
|
||||
// animationScale.setDuration(duration);
|
||||
// animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
|
||||
@@ -351,129 +352,134 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startScaleAnimation(float fromX, float toX, float fromY, float toY, int duration, Interpolator interpolator, OnMarkerAnimationListener listener) {
|
||||
if (isDestroyed()) {
|
||||
public void startScaleAnimation( float fromX, float toX, float fromY, float toY, int duration, Interpolator interpolator, OnMarkerAnimationListener listener ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
MarkerScaleAnimation animationScale = new MarkerScaleAnimation(fromX, toX);
|
||||
animationScale.setDuration(duration*1000);
|
||||
MarkerScaleAnimation animationScale = new MarkerScaleAnimation( fromX, toX );
|
||||
animationScale.setDuration( duration * 1000 );
|
||||
// animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
|
||||
// animationScale.setInterpolator(interpolator);
|
||||
animationScale.setAnimationListener(new MarkerAnimationListener() {
|
||||
animationScale.setAnimationListener( new MarkerAnimationListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(@NotNull Animation animation) {
|
||||
if (isDestroyed()) {
|
||||
public void onAnimationEnd( @NotNull Animation animation ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
if (listener != null) {
|
||||
if ( listener != null ) {
|
||||
listener.onAnimEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(@NotNull Animation animation) {
|
||||
public void onAnimationRepeat( @NotNull Animation animation ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(@NotNull Animation animation) {
|
||||
if (isDestroyed()) {
|
||||
public void onAnimationStart( @NotNull Animation animation ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
if (listener != null) {
|
||||
if ( listener != null ) {
|
||||
listener.onAnimStart();
|
||||
}
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
mMarker.setMarkerScaleAnimation(animationScale);
|
||||
mMarker.setMarkerScaleAnimation( animationScale );
|
||||
mMarker.startAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startJumpAnimation(float high, long duration, Interpolator interpolator, OnMarkerAnimationListener listener) {
|
||||
if (isDestroyed() || high <= 0.0f || interpolator == null || duration < 0) {
|
||||
public void startJumpAnimation( float high, long duration, Interpolator interpolator, OnMarkerAnimationListener listener ) {
|
||||
if ( isDestroyed() || high <= 0.0f || interpolator == null || duration < 0 ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final LonLatPoint latLng = ObjectUtils.fromMogo(getPosition());
|
||||
final LonLatPoint latLng = ObjectUtils.fromMogo( getPosition() );
|
||||
// Point point = AMapWrapper.getAMap().getProjection().toScreenLocation(latLng);
|
||||
// point.y -= WindowUtils.dip2px(AbsMogoApplication.getApp(), high);
|
||||
// LatLng target = AMapWrapper.getAMap().getProjection().fromScreenLocation(point);
|
||||
//使用TranslateAnimation,填写一个需要移动的目标点
|
||||
MarkerTranslateAnimation animation = new MarkerTranslateAnimation(latLng);
|
||||
MarkerTranslateAnimation animation = new MarkerTranslateAnimation( latLng );
|
||||
// animation.setInterpolator(interpolator);
|
||||
animation.setAnimationListener(new MarkerAnimationListener() {
|
||||
animation.setAnimationListener( new MarkerAnimationListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(@NotNull Animation animation) {
|
||||
if (isDestroyed()) {
|
||||
public void onAnimationEnd( @NotNull Animation animation ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
if (listener != null) {
|
||||
if ( listener != null ) {
|
||||
listener.onAnimEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(@NotNull Animation animation) {
|
||||
public void onAnimationRepeat( @NotNull Animation animation ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(@NotNull Animation animation) {
|
||||
if (isDestroyed()) {
|
||||
public void onAnimationStart( @NotNull Animation animation ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
if (listener != null) {
|
||||
if ( listener != null ) {
|
||||
listener.onAnimStart();
|
||||
}
|
||||
}
|
||||
});
|
||||
} );
|
||||
//整个移动所需要的时间
|
||||
animation.setDuration(duration*1000);
|
||||
animation.setDuration( duration * 1000 );
|
||||
//设置动画
|
||||
mMarker.setTranslateAnimation(animation);
|
||||
mMarker.setTranslateAnimation( animation );
|
||||
mMarker.startAnimation();
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "error.");
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClickable(boolean clickable) {
|
||||
if (mMarker != null) {
|
||||
mMarker.setClickable(clickable);
|
||||
public void setClickable( boolean clickable ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setClickable( clickable );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startSmooth(List<MogoLatLng> points, int duration) {
|
||||
if (isDestroyed()) {
|
||||
public void startSmooth( List< MogoLatLng > points, int duration ) {
|
||||
startSmoothInMs( points, duration * 1000 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startSmoothInMs( List< MogoLatLng > points, long duration ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mMarker == null) {
|
||||
if ( mMarker == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (points == null || points.isEmpty()) {
|
||||
if ( points == null || points.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<LonLatPoint> newPoints = new ArrayList<>();
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
LonLatPoint point = ObjectUtils.fromMogo(points.get(i));
|
||||
if (point == null) {
|
||||
List< LonLatPoint > newPoints = new ArrayList<>();
|
||||
for ( int i = 0; i < points.size(); i++ ) {
|
||||
LonLatPoint point = ObjectUtils.fromMogo( points.get( i ) );
|
||||
if ( point == null ) {
|
||||
continue;
|
||||
}
|
||||
newPoints.add(point);
|
||||
newPoints.add( point );
|
||||
}
|
||||
if (newPoints.isEmpty()) {
|
||||
if ( newPoints.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMarker.startSmooth(newPoints,duration*1000);
|
||||
mMarker.startSmooth( newPoints, ( int ) duration );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -492,4 +498,13 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
mMarker.setGps( isGps );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use3DResource( int model3D ) {
|
||||
try {
|
||||
mMarker.setMarkerOptions( mMarker.getMarkeOptions().marker3DIcon( model3D ) );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "use3DResource" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,11 +68,9 @@ public class ObjectUtils {
|
||||
descriptors.add( new BitmapDescriptor( icon ) );
|
||||
}
|
||||
}
|
||||
BitmapDescriptor descriptor = getBitmapDescriptorFromMogo( opt );
|
||||
|
||||
MarkerOptions markerOptions = new MarkerOptions()
|
||||
.position( new LonLatPoint( opt.getLongitude(), opt.getLatitude() ) )
|
||||
.markerIcon( descriptor )
|
||||
.anchor( opt.getU(), opt.getV() )
|
||||
// .icons( descriptors )
|
||||
// .period( opt.getPeriod() )
|
||||
@@ -85,6 +83,10 @@ public class ObjectUtils {
|
||||
// .draggable( opt.isDraggable() )
|
||||
.setInfoWindowOffset( opt.getOffsetX(), opt.getOffsetY() )
|
||||
.zIndex( opt.getzIndex() );
|
||||
BitmapDescriptor descriptor = getBitmapDescriptorFromMogo( opt );
|
||||
if ( descriptor != null ) {
|
||||
markerOptions.markerIcon( descriptor );
|
||||
}
|
||||
if ( opt.getIcon3DRes() != 0 ) {
|
||||
markerOptions.marker3DIcon( opt.getIcon3DRes() );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.map;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/17
|
||||
*
|
||||
* 目前整个坐标按照高德火星坐标为准,故对于高德和自研地图,需要实现不同的转换,达到适应各自地图的目的
|
||||
*/
|
||||
interface CoordinatesTransformer {
|
||||
|
||||
double[] transform( double lat, double lon );
|
||||
}
|
||||
@@ -49,4 +49,6 @@ interface IMogoMapApiBuilder extends IProvider {
|
||||
IMogoTrafficSearch getTrafficSearch();
|
||||
|
||||
int getResIdByIconType( Context context, int iconType );
|
||||
|
||||
CoordinatesTransformer getCoordinatesTransformer();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class MogoLatLng implements Parcelable {
|
||||
public MogoLatLng( double lat, double lon ) {
|
||||
this.lat = lat;
|
||||
this.lng = lon;
|
||||
this.lon = lng;
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
|
||||
@@ -5,6 +5,8 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import androidx.annotation.RawRes;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.marker.anim.OnMarkerAnimationListener;
|
||||
|
||||
@@ -281,14 +283,14 @@ public interface IMogoMarker {
|
||||
* @param listener
|
||||
*/
|
||||
void startScaleAnimationWithAlpha( float fromX,
|
||||
float toX,
|
||||
float fromY,
|
||||
float toY,
|
||||
float fromAlpha,
|
||||
float toAlpha,
|
||||
int duration,
|
||||
Interpolator interpolator,
|
||||
OnMarkerAnimationListener listener );
|
||||
float toX,
|
||||
float fromY,
|
||||
float toY,
|
||||
float fromAlpha,
|
||||
float toAlpha,
|
||||
int duration,
|
||||
Interpolator interpolator,
|
||||
OnMarkerAnimationListener listener );
|
||||
|
||||
|
||||
/**
|
||||
@@ -319,15 +321,32 @@ public interface IMogoMarker {
|
||||
*/
|
||||
void startSmooth( List< MogoLatLng > points, int duration );
|
||||
|
||||
/**
|
||||
* 开始平滑移动,毫秒
|
||||
*
|
||||
* @param points 坐标点
|
||||
* @param duration 时长
|
||||
*/
|
||||
void startSmoothInMs( List< MogoLatLng > points, long duration );
|
||||
|
||||
/**
|
||||
* info window 是否正在显示
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isInfoWindowShowing();
|
||||
|
||||
/**
|
||||
* 设置是否是gps
|
||||
*
|
||||
* @param isGps
|
||||
*/
|
||||
void setGps(boolean isGps);
|
||||
void setGps( boolean isGps );
|
||||
|
||||
/**
|
||||
* 使用3D资源
|
||||
*/
|
||||
default void use3DResource( @RawRes int model3D ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,9 +73,21 @@ public class MogoMarkerOptions extends Observable {
|
||||
*/
|
||||
private boolean mAutoManager = true;
|
||||
|
||||
private @RawRes int mIcon3DRes = 0;
|
||||
private @RawRes
|
||||
int mIcon3DRes = 0;
|
||||
|
||||
public MogoMarkerOptions position( MogoLatLng latLng ){
|
||||
private boolean mIs3DMode = false;
|
||||
|
||||
public MogoMarkerOptions set3DMode( boolean is3DMode ) {
|
||||
mIs3DMode = is3DMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean is3DMode() {
|
||||
return mIs3DMode;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions position( MogoLatLng latLng ) {
|
||||
if ( latLng != null ) {
|
||||
latitude( latLng.lat );
|
||||
longitude( latLng.lon );
|
||||
@@ -83,7 +95,7 @@ public class MogoMarkerOptions extends Observable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions position( MogoLocation location ){
|
||||
public MogoMarkerOptions position( MogoLocation location ) {
|
||||
if ( location != null ) {
|
||||
latitude( location.getLatitude() );
|
||||
longitude( location.getLongitude() );
|
||||
@@ -91,7 +103,7 @@ public class MogoMarkerOptions extends Observable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions position( Location location ){
|
||||
public MogoMarkerOptions position( Location location ) {
|
||||
if ( location != null ) {
|
||||
latitude( location.getLatitude() );
|
||||
longitude( location.getLongitude() );
|
||||
@@ -216,7 +228,7 @@ public class MogoMarkerOptions extends Observable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions icon3DRes(@RawRes int icon3DRes){
|
||||
public MogoMarkerOptions icon3DRes( @RawRes int icon3DRes ) {
|
||||
this.mIcon3DRes = icon3DRes;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.mogo.map;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/17
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class MogoCoordinatesTransformer implements CoordinatesTransformer {
|
||||
|
||||
private CoordinatesTransformer mDelegate;
|
||||
|
||||
private static volatile MogoCoordinatesTransformer sInstance;
|
||||
|
||||
private MogoCoordinatesTransformer(){
|
||||
mDelegate = MogoMapDelegateFactory.getCoordinatesTransformer();
|
||||
}
|
||||
|
||||
public static MogoCoordinatesTransformer getInstance(){
|
||||
if( sInstance == null ){
|
||||
synchronized( MogoCoordinatesTransformer.class ) {
|
||||
if( sInstance == null ){
|
||||
sInstance = new MogoCoordinatesTransformer();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release(){
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] transform( double lat, double lon ) {
|
||||
if ( mDelegate != null ) {
|
||||
return mDelegate.transform( lat, lon );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -133,4 +133,8 @@ class MogoMapDelegateFactory {
|
||||
public static IMogoTrafficSearch getTrafficSearch() {
|
||||
return getApiBuilder().getTrafficSearch();
|
||||
}
|
||||
|
||||
public static CoordinatesTransformer getCoordinatesTransformer(){
|
||||
return getApiBuilder().getCoordinatesTransformer();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user