Merge remote-tracking branch 'origin/dev_custom_map' into dev_custom_map
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
package com.mogo.map.impl.custom;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.map.impl.custom.marker.MarkerWrapperIntance;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MogoMarkersHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidaoauto.map.sdk.open.marker.Marker;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
@@ -18,8 +23,9 @@ public class AMapMarkerClickHandler {
|
||||
if ( marker == null ) {
|
||||
return false;
|
||||
}
|
||||
if ( marker.getMObject() instanceof IMogoMarker ) {
|
||||
IMogoMarker mogoMarker = ( ( IMogoMarker ) marker.getMObject() );
|
||||
Map<String, IMogoMarker> mogoMarkerMap = MarkerWrapperIntance.getInstance().getMogoMarkerMap();
|
||||
if ( mogoMarkerMap.containsKey(marker.getId())) {
|
||||
IMogoMarker mogoMarker = mogoMarkerMap.get(marker.getId());
|
||||
final IMogoMarkerClickListener listener = mogoMarker.getOnMarkerClickListener();
|
||||
Logger.d( "AMapMarkerWrapper", "marker 点击回调:%s -> %s", mogoMarker, marker );
|
||||
if ( listener != null ) {
|
||||
|
||||
@@ -2,10 +2,15 @@ package com.mogo.map.impl.custom.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.impl.custom.AMapWrapper;
|
||||
import com.mogo.map.impl.custom.utils.ObjectUtils;
|
||||
import com.mogo.map.marker.IMogoInfoWindowAdapter;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
@@ -13,7 +18,9 @@ import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.IMogoMarkerIconViewCreator;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.marker.anim.OnMarkerAnimationListener;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidaoauto.map.sdk.inner.marker.MarkerTranslateAnimation;
|
||||
import com.zhidaoauto.map.sdk.open.marker.Marker;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerInfo;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions;
|
||||
@@ -23,6 +30,7 @@ import com.zhidaoauto.map.sdk.open.tools.MapTools;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
@@ -47,12 +55,12 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
private MogoMarkerOptions mMogoMarkerOptions;
|
||||
private String mOwner;
|
||||
|
||||
|
||||
public AMapMarkerWrapper(Marker marker, MogoMarkerOptions mogoMarkerOptions) {
|
||||
this.mMarker = marker;
|
||||
if (marker != null) {
|
||||
// 设置高德 marker 的object对象为 IMogoMarker 实例。!!!!
|
||||
marker.setMObject(this);
|
||||
MarkerWrapperIntance.getInstance().setMogoMarkerMap(marker.getId(),this);
|
||||
}
|
||||
setObject(mogoMarkerOptions.getObject());
|
||||
this.mMogoMarkerOptions = mogoMarkerOptions;
|
||||
@@ -385,12 +393,12 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// final LatLng latLng = ObjectUtils.fromMogo2(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,填写一个需要移动的目标点
|
||||
// Animation animation = new TranslateAnimation(target);
|
||||
//使用TranslateAnimation,填写一个需要移动的目标点
|
||||
MarkerTranslateAnimation animation = new MarkerTranslateAnimation(latLng);
|
||||
// animation.setInterpolator(interpolator);
|
||||
// animation.setAnimationListener(new Animation.AnimationListener() {
|
||||
// @Override
|
||||
@@ -413,11 +421,11 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// //整个移动所需要的时间
|
||||
// animation.setDuration(duration);
|
||||
// //设置动画
|
||||
// mMarker.setAnimation(animation);
|
||||
// mMarker.startAnimation();
|
||||
//整个移动所需要的时间
|
||||
animation.setDuration(duration);
|
||||
//设置动画
|
||||
mMarker.setAnimation(animation);
|
||||
mMarker.startAnimation();
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "error.");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mogo.map.impl.custom.marker;
|
||||
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.zhidaoauto.map.sdk.open.marker.Marker;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MarkerWrapperIntance {
|
||||
public static MarkerWrapperIntance markerWrapperIntance;
|
||||
private Map<String, IMogoMarker> mogoMarkerMap = new HashMap<>();
|
||||
public void setMogoMarkerMap(String id,IMogoMarker iMogoMarker){
|
||||
this.mogoMarkerMap.put(id,iMogoMarker);
|
||||
}
|
||||
|
||||
public Map<String, IMogoMarker> getMogoMarkerMap() {
|
||||
return mogoMarkerMap;
|
||||
}
|
||||
|
||||
public static MarkerWrapperIntance getInstance(){
|
||||
if (markerWrapperIntance == null){
|
||||
markerWrapperIntance = new MarkerWrapperIntance();
|
||||
}
|
||||
return markerWrapperIntance;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user