[MAP] 高精地图Marker绘制逻辑重构
This commit is contained in:
@@ -1,77 +0,0 @@
|
||||
package com.mogo.map;
|
||||
|
||||
import static com.mogo.map.marker.MarkerType.MAP_STATIC;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.map.marker.AMapMarkerWrapper;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MarkerWrapperClickHelper;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.marker.MogoMarkersHandler;
|
||||
import com.zhidaoauto.map.sdk.open.marker.Marker;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* marker 点击事件处理
|
||||
*/
|
||||
public class AMapMarkerClickHandler {
|
||||
|
||||
private static volatile AMapMarkerClickHandler sInstance;
|
||||
|
||||
private AMapMarkerClickHandler() {
|
||||
}
|
||||
|
||||
public static AMapMarkerClickHandler getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (AMapMarkerClickHandler.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new AMapMarkerClickHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public boolean handleMarkerClicked(Marker marker) {
|
||||
if (marker == null) {
|
||||
return false;
|
||||
}
|
||||
//地图道路上静态数,暂时只过滤traffic类型下发点击事件
|
||||
if (MarkerWrapperClickHelper.getInstance().isStaticMarker(marker.getId())){
|
||||
IMogoMarker iMogoMarker = new AMapMarkerWrapper(marker,new MogoMarkerOptions());
|
||||
iMogoMarker.setOwner(MAP_STATIC); //TODO 后续可能由于类型比较多,需要owner匹配机制,以及控制owner细粒度
|
||||
CallerLogger.INSTANCE.d("AMapMarkerWrapper", "traffic marker 点击回调");
|
||||
return MogoMarkersHandler.Companion.getMogoMarkersHandler().onStaticMarkerClicked(iMogoMarker);
|
||||
}
|
||||
|
||||
Map<String, IMogoMarker> mogoMarkerMap = MarkerWrapperClickHelper.getInstance().getMogoMarkerMap();
|
||||
if (mogoMarkerMap.containsKey(marker.getId())) {
|
||||
IMogoMarker mogoMarker = mogoMarkerMap.get(marker.getId());
|
||||
final IMogoMarkerClickListener listener = mogoMarker.getOnMarkerClickListener();
|
||||
CallerLogger.INSTANCE.d("AMapMarkerWrapper", "marker 点击回调:%s -> %s", mogoMarker, marker);
|
||||
if (listener != null) {
|
||||
boolean result = listener.onMarkerClicked(mogoMarker);
|
||||
if (result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return MogoMarkersHandler.Companion.getMogoMarkersHandler().onMarkerClicked(mogoMarker);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,6 +46,7 @@ import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.hdcache.IHdCacheListener;
|
||||
import com.mogo.map.identify.MogoIdentifyManager;
|
||||
import com.mogo.map.listener.MogoMapListenerHandler;
|
||||
import com.mogo.map.location.GDLocationClient;
|
||||
import com.mogo.map.uicontroller.CarCursorOption;
|
||||
@@ -112,8 +113,6 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
private static final String TAG = "AMapViewWrapper";
|
||||
private final MapAutoView mMapView;
|
||||
private final IMogoMap mIMap;
|
||||
private AMapMarkerClickHandler mMarkerClickHandler;
|
||||
|
||||
private final CarCursorOption DEFAULT_OPTION = new CarCursorOption.Builder()
|
||||
.carCursorRes(R.drawable.map_api_ic_current_location2)
|
||||
.naviCursorRes(R.drawable.ic_amap_navi_cursor)
|
||||
@@ -187,7 +186,6 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
|
||||
private void initListeners() {
|
||||
mMapView.setOnMarkClickListener(this);
|
||||
mMarkerClickHandler = AMapMarkerClickHandler.getInstance();
|
||||
mMapView.setOnMapLoadedListener(this);
|
||||
mMapView.setOnMapTouchListener(this);
|
||||
mMapView.setOnMapClickListener(this);
|
||||
@@ -768,7 +766,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
|
||||
@Override
|
||||
public void onMarkClick(@NotNull Marker markerInfo) {
|
||||
mMarkerClickHandler.handleMarkerClicked(markerInfo);
|
||||
// mMarkerClickHandler.handleMarkerClicked(markerInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -958,12 +956,12 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
if (isDayMode()) {
|
||||
preVehicleStrWeiZhi =
|
||||
// 添加模型到地图中
|
||||
MogoMarkerManager.getInstance(getContext())
|
||||
MogoIdentifyManager.getInstance(getContext())
|
||||
.addPreVehicleModel(typeTrafficId.getType(), typeTrafficId.getTraffic3DIconId());
|
||||
} else {
|
||||
preVehicleStrWeiZhi =
|
||||
// 添加模型到地图中
|
||||
MogoMarkerManager.getInstance(getContext())
|
||||
MogoIdentifyManager.getInstance(getContext())
|
||||
.addPreVehicleModel(typeTrafficId.getType(), typeTrafficId.getTraffic3DNightIconId());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,18 @@
|
||||
package com.mogo.map;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.map.center.CenterLine;
|
||||
import com.mogo.map.marker.AMapInfoWindowAdapter;
|
||||
import com.mogo.map.marker.AMapMarkerWrapper;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.marker.MogoMarkersHandler;
|
||||
import com.mogo.map.overlay.AMapPolylineWrapper;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.map.overlay.proxy.line.IMapPolylineOverlay;
|
||||
import com.mogo.map.overlay.proxy.point.IMapPointOverlay;
|
||||
import com.mogo.map.overlay.wrapper.point.AMapPointWrapper;
|
||||
import com.mogo.map.road.RoadNameInfo;
|
||||
import com.mogo.map.uicontroller.AMapUIController;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.map.utils.ObjectUtils;
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi;
|
||||
import com.zhidaoauto.map.sdk.open.data.MapDataApi;
|
||||
import com.zhidaoauto.map.sdk.open.data.SinglePointRoadInfo;
|
||||
import com.zhidaoauto.map.sdk.open.marker.BatchMarkerOptions;
|
||||
@@ -28,7 +20,6 @@ import com.zhidaoauto.map.sdk.open.marker.Marker;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerHelper;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerSimpleData;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MultiPointOverlayOptions;
|
||||
import com.zhidaoauto.map.sdk.open.poyline.Polyline;
|
||||
import com.zhidaoauto.map.sdk.open.poyline.PolylineOptions;
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
|
||||
@@ -55,9 +46,9 @@ public class AMapWrapper implements IMogoMap {
|
||||
private static final String TAG = "AMapWrapper";
|
||||
|
||||
private static MapAutoViewHelper sAMap;
|
||||
private IMogoMapUIController mMapUIController;
|
||||
private final IMogoMapUIController mMapUIController;
|
||||
private MapAutoViewHelper mAMap;
|
||||
private MapAutoView mMapView;
|
||||
private final MapAutoView mMapView;
|
||||
private IMogoUiSettings mUiSettings;
|
||||
|
||||
public AMapWrapper(MapAutoViewHelper map, MapAutoView mapView, IMogoMapUIController controller) {
|
||||
@@ -67,7 +58,7 @@ public class AMapWrapper implements IMogoMap {
|
||||
this.mMapView = mapView;
|
||||
mMapUIController = controller;
|
||||
// 设置实现自定义 info window
|
||||
MapAutoApi.INSTANCE.setInfoWindowAdapter(new AMapInfoWindowAdapter());
|
||||
// MapAutoApi.INSTANCE.setInfoWindowAdapter(new AMapInfoWindowAdapter());
|
||||
AMapUIController.getInstance().initClient(mMapUIController);
|
||||
}
|
||||
|
||||
@@ -92,7 +83,7 @@ public class AMapWrapper implements IMogoMap {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarker addMarker(String tag, MogoMarkerOptions options) {
|
||||
public IMapPointOverlay addPoint(com.mogo.map.overlay.point.Point.Options options) {
|
||||
if (!checkAMap()) {
|
||||
return null;
|
||||
}
|
||||
@@ -101,18 +92,28 @@ public class AMapWrapper implements IMogoMap {
|
||||
CallerLogger.INSTANCE.e(TAG, "marker参数为空");
|
||||
return null;
|
||||
}
|
||||
final IMogoMarker mogoMarker = new AMapMarkerWrapper(mAMap.addMarker(markerOptions), options);
|
||||
if (options.isAutoManager()) {
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().add(tag, mogoMarker);
|
||||
Marker delegate = mAMap.addMarker(markerOptions);
|
||||
if (delegate == null) {
|
||||
return null;
|
||||
}
|
||||
return mogoMarker;
|
||||
return new AMapPointWrapper(options.getId(), delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllMarkers() {
|
||||
if (sAMap != null) {
|
||||
sAMap.clearAllMarkers();
|
||||
public IMapPolylineOverlay addLine(com.mogo.map.overlay.line.Polyline.Options options) {
|
||||
if (!checkAMap()) {
|
||||
return null;
|
||||
}
|
||||
PolylineOptions polylineOptions = ObjectUtils.fromMogo(options);
|
||||
if (polylineOptions == null) {
|
||||
CallerLogger.INSTANCE.e(TAG, "polyline参数为空");
|
||||
return null;
|
||||
}
|
||||
Polyline delegate = polylineOptions.lineWidth > 0 ? mAMap.drawThickLine(polylineOptions) : mAMap.drawLine(polylineOptions);
|
||||
if (delegate == null) {
|
||||
return null;
|
||||
}
|
||||
return new com.mogo.map.overlay.wrapper.line.AMapPolylineWrapper(options.getId(), delegate);
|
||||
}
|
||||
|
||||
BatchMarkerOptions batchMarkerOptions = new BatchMarkerOptions();
|
||||
@@ -197,53 +198,6 @@ public class AMapWrapper implements IMogoMap {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<IMogoMarker> addMarkers(String tag, ArrayList<MogoMarkerOptions> options, boolean moveToCenter) {
|
||||
if (!checkAMap()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (options == null || options.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ArrayList<Marker> markers = new ArrayList<>();
|
||||
ArrayList<MarkerOptions> markerOptions = new ArrayList<>();
|
||||
ArrayList<IMogoMarker> mogoMarkers = new ArrayList<>();
|
||||
for (MogoMarkerOptions option : options) {
|
||||
if (option == null) {
|
||||
continue;
|
||||
}
|
||||
MarkerOptions mo = ObjectUtils.fromMogo(option);
|
||||
if (mo == null) {
|
||||
continue;
|
||||
}
|
||||
markerOptions.add(mo);
|
||||
}
|
||||
if (markerOptions.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
MultiPointOverlayOptions multiPointOverlayOptions = new MultiPointOverlayOptions();
|
||||
multiPointOverlayOptions.setData(markerOptions);
|
||||
multiPointOverlayOptions.setMarkerIcon(R.drawable.marker_blue);
|
||||
List<MarkerOptions> data = mAMap.addMarkers(multiPointOverlayOptions).getOptions().getData();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
markers.add(new Marker(data.get(i)));
|
||||
}
|
||||
if (markers == null || markers.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < markers.size(); i++) {
|
||||
Marker marker = markers.get(i);
|
||||
if (marker == null) {
|
||||
continue;
|
||||
}
|
||||
mogoMarkers.add(new AMapMarkerWrapper(marker, options.get(i)));
|
||||
}
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().add(tag, mogoMarkers);
|
||||
return mogoMarkers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
if (checkAMap()) {
|
||||
@@ -287,32 +241,13 @@ public class AMapWrapper implements IMogoMap {
|
||||
if (checkAMap()) {
|
||||
try {
|
||||
return mAMap.getZoom();
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoPolyline addPolyline(MogoPolylineOptions options) {
|
||||
if (checkAMap()) {
|
||||
PolylineOptions polylineOptions = ObjectUtils.fromMogo(options);
|
||||
CallerLogger.INSTANCE.d(TAG, "addPolyline %s", polylineOptions.toString());
|
||||
if (polylineOptions == null) {
|
||||
return null;
|
||||
}
|
||||
Polyline polyline = null;
|
||||
if (polylineOptions.getLineWidth() > 0) {
|
||||
polyline = mAMap.drawThickLine(polylineOptions);
|
||||
} else {
|
||||
polyline = mAMap.drawLine(polylineOptions);
|
||||
}
|
||||
return new AMapPolylineWrapper(polyline, options);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean checkAMap() {
|
||||
mAMap = mMapView.getMapAutoViewHelper();
|
||||
sAMap = mAMap;
|
||||
@@ -365,8 +300,4 @@ public class AMapWrapper implements IMogoMap {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private Context getContext() {
|
||||
return mMapView.getContext();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.mogo.map
|
||||
|
||||
import com.mogo.map.overlay.*
|
||||
|
||||
object MoGoOverlayManager {
|
||||
|
||||
private val impl by lazy { MoGoOverlayManagerImpl() }
|
||||
|
||||
fun overlay(): IMoGoOverlayManager = impl
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
package com.mogo.map;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.call.v2x.CallMarkersClearManager;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.marker.MogoMarkersHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo.yycp.api.proto.SocketDownData;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-20
|
||||
* <p>
|
||||
* marker 管理实现
|
||||
*/
|
||||
public class MogoMarkerManager implements IMogoMarkerManager {
|
||||
|
||||
private static final String TAG = "MogoMarkerManager";
|
||||
|
||||
private static volatile MogoMarkerManager sInstance;
|
||||
private Context mApplicationContext;
|
||||
|
||||
private MogoMarkerManager(Context context) {
|
||||
if (context != null) {
|
||||
mApplicationContext = context.getApplicationContext();
|
||||
}
|
||||
}
|
||||
|
||||
public static MogoMarkerManager getInstance(Context context) {
|
||||
if (sInstance == null) {
|
||||
synchronized (MogoMarkerManager.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new MogoMarkerManager(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarker addMarker(String tag, MogoMarkerOptions options) {
|
||||
try {
|
||||
return MogoMap.getInstance().getMogoMap().addMarker(tag, options);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IMogoMarker> addMarkers(String tag, ArrayList<MogoMarkerOptions> options, boolean moveToCenter) {
|
||||
try {
|
||||
return MogoMap.getInstance().getMogoMap().addMarkers(tag, options, moveToCenter);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllMarker() {
|
||||
try{
|
||||
MogoMap.getInstance().getMogoMap().clearAllMarkers();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBatchMarkerPosition(HashMap<String, MessagePad.TrackedObject> optionsArrayList) {
|
||||
try {
|
||||
MogoMap.getInstance().getMogoMap().updateBatchMarkerPosition(optionsArrayList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBatchAiMarkerPosition(HashMap<String, SocketDownData.CloudRoadDataProto> optionsArrayList) {
|
||||
try {
|
||||
MogoMap.getInstance().getMogoMap().updateBatchAiMarkerPosition(optionsArrayList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addPreVehicleModel(int type, int modelRes) {
|
||||
try {
|
||||
return MogoMap.getInstance().getMogoMap().addPreVehicleModel(type, modelRes);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMarker(String uuidString) {
|
||||
try {
|
||||
MogoMap.getInstance().getMogoMap().removeMarker(uuidString);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeMarkers(String tag) {
|
||||
CallMarkersClearManager.INSTANCE.invokeClearAllMarkersOfTag(tag);
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().remove(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMarkers() {
|
||||
CallMarkersClearManager.INSTANCE.invokeClearAllMarkers();
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().removeAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visibleAllMarkers() {
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().visibleAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inVisibleAllMarkers() {
|
||||
CallMarkersClearManager.INSTANCE.invokeClearAllMarkers();
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().inVisibleAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inVisibleWithoutMarkers(String... owner) {
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().inVisibleMarkers(owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IMogoMarker> getMarkers(String tag) {
|
||||
return MogoMarkersHandler.Companion.getMogoMarkersHandler().getMarkers(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<IMogoMarker>> getAllMarkers() {
|
||||
return MogoMarkersHandler.Companion.getMogoMarkersHandler().getAllMarkers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMarkersExcept(String tag) {
|
||||
MogoMarkersHandler.Companion.getMogoMarkersHandler().deleteAllExcept(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRouteWay(Context context, MogoLatLng startPoint, MogoLatLng endPoint, List<MogoLatLng> wayPoints) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRouteWayOverlay() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mogo.map;
|
||||
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-10
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MogoOverlayManager implements IMogoOverlayManager {
|
||||
|
||||
private MogoOverlayManager() {
|
||||
// private constructor
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
private static final MogoOverlayManager INSTANCE = new MogoOverlayManager();
|
||||
}
|
||||
|
||||
public static MogoOverlayManager getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoPolyline addPolyline(MogoPolylineOptions options) {
|
||||
try {
|
||||
return MogoMap.getInstance().getMogoMap().addPolyline(options);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.mogo.map.identify;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.map.MogoMap;
|
||||
import com.mogo.map.identity.IMogoIdentifyManager;
|
||||
import java.util.HashMap;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo.yycp.api.proto.SocketDownData;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-20
|
||||
* <p>
|
||||
* marker 管理实现
|
||||
*/
|
||||
public class MogoIdentifyManager implements IMogoIdentifyManager {
|
||||
|
||||
private static final String TAG = "MogoIdentifyManager";
|
||||
|
||||
private static volatile MogoIdentifyManager sInstance;
|
||||
|
||||
private MogoIdentifyManager(Context context) {}
|
||||
|
||||
public static MogoIdentifyManager getInstance(Context context) {
|
||||
if (sInstance == null) {
|
||||
synchronized (MogoIdentifyManager.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new MogoIdentifyManager(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMarker(String uuidString) {
|
||||
try {
|
||||
MogoMap.getInstance().getMogoMap().removeMarker(uuidString);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBatchMarkerPosition(HashMap<String, MessagePad.TrackedObject> optionsArrayList) {
|
||||
try {
|
||||
MogoMap.getInstance().getMogoMap().updateBatchMarkerPosition(optionsArrayList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBatchAiMarkerPosition(HashMap<String, SocketDownData.CloudRoadDataProto> optionsArrayList) {
|
||||
try {
|
||||
MogoMap.getInstance().getMogoMap().updateBatchAiMarkerPosition(optionsArrayList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addPreVehicleModel(int type, int modelRes) {
|
||||
try {
|
||||
return MogoMap.getInstance().getMogoMap().addPreVehicleModel(type, modelRes);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.map.AMapMarkerClickHandler;
|
||||
import com.zhidaoauto.map.sdk.open.abs.marker.InfoWindowAdapter;
|
||||
import com.zhidaoauto.map.sdk.open.marker.Marker;
|
||||
import com.zhidaoauto.map.sdk.open.marker.OnInfoWindowClickListener;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* 自定义infowindow
|
||||
*/
|
||||
public final class AMapInfoWindowAdapter implements InfoWindowAdapter, OnInfoWindowClickListener {
|
||||
|
||||
@Override
|
||||
public View getInfoWindow(Marker marker ) {
|
||||
if ( marker.getMObject() instanceof IMogoMarker ) {
|
||||
IMogoMarker mogoMarker = ( ( IMogoMarker ) marker.getMObject() );
|
||||
IMogoInfoWindowAdapter delegate = mogoMarker.getInfoWindowAdapter();
|
||||
if ( delegate != null ) {
|
||||
final View infoView = delegate.getInfoWindow( mogoMarker );
|
||||
marker.setOnInfoWindowClickListener( this );
|
||||
return infoView;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInfoWindowClick( @NotNull Marker marker ) {
|
||||
AMapMarkerClickHandler.getInstance().handleMarkerClicked( marker );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View getInfoContents( @Nullable Marker marker ) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,338 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.text.TextUtils;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.marker.anim.OnMarkerAnimationListener;
|
||||
import com.mogo.map.utils.ObjectUtils;
|
||||
import com.zhidaoauto.map.sdk.open.abs.marker.MarkerAnimationListener;
|
||||
import com.zhidaoauto.map.sdk.open.marker.Animation;
|
||||
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptor;
|
||||
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptorFactory;
|
||||
import com.zhidaoauto.map.sdk.open.marker.Marker;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerScaleAnimation;
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-18
|
||||
* <p>
|
||||
* 自研marker
|
||||
*/
|
||||
public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
|
||||
private final String TAG = AMapMarkerWrapper.class.getName();
|
||||
|
||||
private Marker mMarker;
|
||||
private Object mObject;
|
||||
private IMogoMarkerClickListener mMogoMarkerClickListener;
|
||||
private IMogoInfoWindowAdapter mMogoInfoWindowAdapter;
|
||||
|
||||
private boolean mIsDestroy = false;
|
||||
|
||||
private MogoMarkerOptions mMogoMarkerOptions;
|
||||
private String mOwner;
|
||||
|
||||
public AMapMarkerWrapper( Marker marker, MogoMarkerOptions mogoMarkerOptions ) {
|
||||
this.mMarker = marker;
|
||||
if ( marker != null ) {
|
||||
// 设置自研 marker 的object对象为 IMogoMarker 实例。!!!!
|
||||
marker.setMObject( this );
|
||||
if ( !TextUtils.isEmpty( mogoMarkerOptions.getAnchorColor() ) ) {
|
||||
marker.setAnchorColor( mogoMarkerOptions.getAnchorColor() );
|
||||
}
|
||||
MarkerWrapperClickHelper.getInstance().setMogoMarkerMap( marker.getId(), this );
|
||||
}
|
||||
setObject( mogoMarkerOptions.getObject() );
|
||||
this.mMogoMarkerOptions = mogoMarkerOptions;
|
||||
mMogoMarkerOptions.addObserver( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update( Observable o, Object arg ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
setMarkerOptions( mMogoMarkerOptions );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
synchronized (this) {
|
||||
if ( mMogoMarkerOptions != null ) {
|
||||
mMogoMarkerOptions.deleteObservers();
|
||||
mMogoMarkerOptions = null;
|
||||
}
|
||||
if ( mMarker != null ) {
|
||||
mMarker.remove();
|
||||
mMarker.setMObject( null );
|
||||
mMarker.setOnInfoWindowClickListener( null );
|
||||
mMarker = null;
|
||||
}
|
||||
}
|
||||
mMogoInfoWindowAdapter = null;
|
||||
mMogoMarkerClickListener = null;
|
||||
mObject = null;
|
||||
mIsDestroy = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
destroy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setAlpha( float alpha ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setAlpha( alpha );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIcon( Bitmap icon ) {
|
||||
if ( icon == null || icon.isRecycled() ) {
|
||||
return;
|
||||
}
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setIcon( icon );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIcons( ArrayList< Bitmap > icons ) {
|
||||
if ( icons == null || icons.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
ArrayList< BitmapDescriptor > descriptors = new ArrayList<>();
|
||||
for ( Bitmap icon : icons ) {
|
||||
if ( icon == null || icon.isRecycled() ) {
|
||||
continue;
|
||||
}
|
||||
descriptors.add( BitmapDescriptorFactory.INSTANCE.fromBitmap( icon ) );
|
||||
}
|
||||
if ( descriptors.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setIcons( descriptors );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarkerOptions( MogoMarkerOptions opt ) {
|
||||
|
||||
final MarkerOptions options = ObjectUtils.fromMogo( opt );
|
||||
if ( options == null ) {
|
||||
return;
|
||||
}
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setMarkerOptions( options );
|
||||
setObject( opt.getObject() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObject( Object object ) {
|
||||
mObject = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject() {
|
||||
return mObject;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPosition( double lat, double lng ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setPosition( new LonLatPoint( lng, lat ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getPosition() {
|
||||
if ( mMarker != null ) {
|
||||
final LonLatPoint latLng = mMarker.getPosition();
|
||||
return ObjectUtils.fromAMap( latLng );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotateAngle( float rotate ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setRotateAngle( rotate );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitle( String title ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setTitle( title );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToTop() {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setToTop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible( boolean visible ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setVisible( visible );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setOnMarkerClickListener( IMogoMarkerClickListener listener ) {
|
||||
mMogoMarkerClickListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerClickListener getOnMarkerClickListener() {
|
||||
return mMogoMarkerClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoInfoWindowAdapter getInfoWindowAdapter() {
|
||||
return mMogoInfoWindowAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDestroyed() {
|
||||
return mIsDestroy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwner( String mOwner ) {
|
||||
this.mOwner = mOwner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwner() {
|
||||
if ( mOwner != null ) {
|
||||
return mOwner;
|
||||
}
|
||||
if ( mMogoMarkerOptions != null ) {
|
||||
return mMogoMarkerOptions.getOwner();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Marker getMarker() {
|
||||
return mMarker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoMarkerOptions getMogoMarkerOptions() {
|
||||
return mMogoMarkerOptions;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void startScaleAnimation(float fromX, float toX, float fromY, float toY, int duration, Interpolator interpolator, final OnMarkerAnimationListener listener ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
MarkerScaleAnimation animationScale = new MarkerScaleAnimation( fromX, toX );
|
||||
animationScale.setDuration( duration );
|
||||
// animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
|
||||
// animationScale.setInterpolator(interpolator);
|
||||
animationScale.setAnimationListener( new MarkerAnimationListener() {
|
||||
@Override
|
||||
public void onAnimationEnd( @NotNull Animation animation ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
if ( listener != null ) {
|
||||
listener.onAnimEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat( @NotNull Animation animation ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart( @NotNull Animation animation ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
if ( listener != null ) {
|
||||
listener.onAnimStart();
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
mMarker.setMarkerScaleAnimation( animationScale );
|
||||
mMarker.startAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClickable( boolean clickable ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setClickable( clickable );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setGps( boolean isGps ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setGps( isGps );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String mLastAnchorColor = "";
|
||||
|
||||
@Override
|
||||
public void setAnchorColor( String anchorColor ) {
|
||||
if ( TextUtils.equals( mLastAnchorColor, anchorColor ) ) {
|
||||
return;
|
||||
}
|
||||
if (mMogoMarkerOptions != null) {
|
||||
mMogoMarkerOptions.anchorColor( anchorColor );
|
||||
}
|
||||
|
||||
if (mMarker != null) {
|
||||
mMarker.setAnchorColor( anchorColor );
|
||||
}
|
||||
mLastAnchorColor = anchorColor;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addDynamicAnchorPosition( MogoLatLng latLng, float angle, long duration ) {
|
||||
mMarker.addDynamicAnchorPostion( new LonLatPoint( latLng.lon, latLng.lat, angle ), System.currentTimeMillis(), ( int ) duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMarkerResName() {
|
||||
if ( mMarker != null ) {
|
||||
try {
|
||||
return mMarker.getMarkeOptions().getMarkerIconName();
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MarkerWrapperClickHelper {
|
||||
|
||||
private volatile static MarkerWrapperClickHelper markerWrapperClickHelper;
|
||||
|
||||
private final Map<String, IMogoMarker> mogoMarkerMap = new HashMap<>();
|
||||
|
||||
private MarkerWrapperClickHelper(){
|
||||
|
||||
}
|
||||
|
||||
public void setMogoMarkerMap(String id,IMogoMarker iMogoMarker){
|
||||
if(isStaticMarker(id)){
|
||||
return;
|
||||
}
|
||||
this.mogoMarkerMap.put(id,iMogoMarker);
|
||||
}
|
||||
|
||||
public Map<String, IMogoMarker> getMogoMarkerMap() {
|
||||
return mogoMarkerMap;
|
||||
}
|
||||
|
||||
public static MarkerWrapperClickHelper getInstance(){
|
||||
if (markerWrapperClickHelper == null) {
|
||||
synchronized (MarkerWrapperClickHelper.class) {
|
||||
if (markerWrapperClickHelper == null) {
|
||||
markerWrapperClickHelper = new MarkerWrapperClickHelper();
|
||||
}
|
||||
}
|
||||
}
|
||||
return markerWrapperClickHelper;
|
||||
}
|
||||
|
||||
public boolean isStaticMarker(String id){
|
||||
return id.contains("traffic");
|
||||
}
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
package com.mogo.map.overlay;
|
||||
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.utils.ObjectUtils;
|
||||
import com.zhidaoauto.map.sdk.open.poyline.Polyline;
|
||||
import com.zhidaoauto.map.sdk.open.poyline.PolylineOptions;
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-10
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AMapPolylineWrapper implements IMogoPolyline {
|
||||
|
||||
private Polyline mPolyline;
|
||||
private MogoPolylineOptions mOptions;
|
||||
private boolean mIsDestroyed = false;
|
||||
|
||||
public AMapPolylineWrapper( Polyline mPolyline,
|
||||
MogoPolylineOptions mOptions ) {
|
||||
this.mPolyline = mPolyline;
|
||||
this.mOptions = mOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
mIsDestroyed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
if ( mPolyline != null ) {
|
||||
return mPolyline.getId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPoints( List< MogoLatLng > lonLats ) {
|
||||
if ( lonLats == null || lonLats.isEmpty() ) {
|
||||
mPolyline.setPoints( new ArrayList<LonLatPoint>() );
|
||||
return;
|
||||
}
|
||||
ArrayList< LonLatPoint > points = new ArrayList<>();
|
||||
for ( MogoLatLng lonLat : lonLats ) {
|
||||
LonLatPoint latLng = ObjectUtils.fromMogo( lonLat );
|
||||
if ( latLng == null ) {
|
||||
continue;
|
||||
}
|
||||
points.add( latLng );
|
||||
}
|
||||
mPolyline.setPoints( points );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List< MogoLatLng > getPoints() {
|
||||
if ( mPolyline == null ) {
|
||||
return null;
|
||||
}
|
||||
ArrayList< MogoLatLng > lonLats = new ArrayList<>();
|
||||
List<LonLatPoint> points = mPolyline.getPoints();
|
||||
if ( points != null ) {
|
||||
for ( LonLatPoint latLng : points ) {
|
||||
MogoLatLng lonLat = ObjectUtils.fromAMap( latLng );
|
||||
if ( lonLat == null ) {
|
||||
continue;
|
||||
}
|
||||
lonLats.add( lonLat );
|
||||
}
|
||||
}
|
||||
return lonLats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGeodesic( boolean draw ) {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setGeodesic( draw );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGeodesic() {
|
||||
return mPolyline == null ? false : mPolyline.isGeodesic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDottedLine( boolean dottedLine ) {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setDottedLine( dottedLine );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDottedLine() {
|
||||
return mPolyline == null ? false : mPolyline.isDottedLine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWidth( float width ) {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setWidth( width );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWidth() {
|
||||
if ( mPolyline != null ) {
|
||||
return mPolyline.getWidth();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor( int color ) {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setColor( color );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
if ( mPolyline != null ) {
|
||||
return mPolyline.getColor();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZIndex( float zIndex ) {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setZIndex( zIndex );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getZIndex() {
|
||||
if ( mPolyline != null ) {
|
||||
return mPolyline.getZIndex();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible( boolean visible ) {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setVisible( visible );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
if ( mPolyline != null ) {
|
||||
return mPolyline.isVisible();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransparency( float transparency ) {
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setTransparency( transparency );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOption( MogoPolylineOptions option ) {
|
||||
PolylineOptions target = ObjectUtils.fromMogo( option );
|
||||
if ( target == null ) {
|
||||
return;
|
||||
}
|
||||
mOptions = option;
|
||||
if ( mPolyline != null ) {
|
||||
mPolyline.setOption( target );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDestroyed() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,448 @@
|
||||
package com.mogo.map.overlay
|
||||
|
||||
import android.graphics.*
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.function.call.map.*
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.mogo.map.overlay.point.Point.Options
|
||||
import com.mogo.map.*
|
||||
import com.mogo.map.overlay.core.*
|
||||
import com.mogo.map.overlay.line.*
|
||||
import com.mogo.map.overlay.point.Point
|
||||
import com.mogo.map.overlay.proxy.line.*
|
||||
import com.mogo.map.overlay.proxy.point.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
internal class MoGoOverlayManagerImpl: IMoGoOverlayManager {
|
||||
|
||||
private val points by lazy { ConcurrentHashMap<Point, IMapPointOverlay>() }
|
||||
|
||||
private val lines by lazy { ConcurrentHashMap<Polyline, IMapPolylineOverlay>() }
|
||||
|
||||
override fun showOrUpdatePoint(options: Options): Point? {
|
||||
synchronized(points) {
|
||||
val key = Point(options.id, options.owner, options.level, options)
|
||||
var point = points[key]
|
||||
try {
|
||||
if (point != null) {
|
||||
point.setOptions(options)
|
||||
return key
|
||||
} else {
|
||||
val p = MogoMap.getInstance().mogoMap.addPoint(options)
|
||||
if (p != null) {
|
||||
p.onRemove { removed ->
|
||||
val keys = points.filterKeys { it.id == removed }
|
||||
if (keys.isNotEmpty()) {
|
||||
keys.forEach {
|
||||
points.remove(it.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
points[key] = p
|
||||
point = p
|
||||
return key
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
point?.also {
|
||||
key.delegate = point
|
||||
it.setToTop()
|
||||
if (options.moveToCenter) {
|
||||
moveToCenter(
|
||||
options.id,
|
||||
options.longitude,
|
||||
options.latitude,
|
||||
if (options.isGps) CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().longitude else CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().longitude,
|
||||
if (options.isGps) CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().latitude else CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().latitude
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
override fun hidePoint(id: String) {
|
||||
points.filter { it.key.id == id && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hidePoint(p: Point) {
|
||||
points.filter { it.key == p && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllPointsInOwner(owner: String) {
|
||||
points.filter { it.key.owner == owner && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllPointsInLevel(level: Level) {
|
||||
points.filter { it.key.level == level && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllPoints() {
|
||||
points.filter { it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removePoint(id: String) {
|
||||
synchronized(points) {
|
||||
val keys = ArrayList<Point>()
|
||||
points.filter { it.key.id == id }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
points.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removePoint(p: Point) {
|
||||
synchronized(points) {
|
||||
val keys = ArrayList<Point>()
|
||||
points.filter { it.key == p }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
points.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeAllPointsInOwner(owner: String) {
|
||||
synchronized(points) {
|
||||
val keys = ArrayList<Point>()
|
||||
points.filter { it.key.owner == owner }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
points.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeAllPointsInLevel(level: Level) {
|
||||
synchronized(points) {
|
||||
val keys = ArrayList<Point>()
|
||||
points.filter { it.key.level == level && it.value.isVisible() }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
points.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeAllPoints() {
|
||||
synchronized(points){
|
||||
points.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}
|
||||
points.clear()
|
||||
}
|
||||
}
|
||||
|
||||
override fun showAllPoints() {
|
||||
points.filter { !it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showAllPointsInOwner(owner: String) {
|
||||
points.filter { it.key.owner == owner && !it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showAllPointsInLevel(level: Level) {
|
||||
points.filter { it.key.level == level && !it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showPoint(id: String) {
|
||||
points.filter { it.key.id == id && !it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showOrUpdateLine(options: Polyline.Options): Polyline? {
|
||||
synchronized(lines) {
|
||||
val key = Polyline(options.id, options.owner, options.level, options)
|
||||
var line = lines[key]
|
||||
try {
|
||||
if (line != null) {
|
||||
line.setOptions(options)
|
||||
return key
|
||||
} else {
|
||||
val newLine = MogoMap.getInstance().mogoMap.addLine(options)
|
||||
if (newLine != null) {
|
||||
newLine.onRemove { removed ->
|
||||
val keys = lines.filterKeys { it.id == removed }
|
||||
if (keys.isNotEmpty()) {
|
||||
keys.forEach {
|
||||
lines.remove(it.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
lines[key] = newLine
|
||||
line = newLine
|
||||
return key
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
line?.also {
|
||||
it.setToTop()
|
||||
key.delegate = it
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
private fun moveToCenter(id: String, eventLon: Double, eventLat: Double, carLon: Double, carLat: Double) {
|
||||
try {
|
||||
CallerMapUIServiceManager.getMapUIController()?.showBounds(
|
||||
id,
|
||||
MogoLatLng(carLat, carLon),
|
||||
listOf(MogoLatLng(eventLat, eventLon)),
|
||||
Rect(
|
||||
WindowUtils.dip2px(Utils.getApp(), 100f),
|
||||
WindowUtils.dip2px(Utils.getApp(), 370f),
|
||||
WindowUtils.dip2px(Utils.getApp(), 575f),
|
||||
WindowUtils.dip2px(Utils.getApp(), 100f)
|
||||
), true)
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideLine(id: String) {
|
||||
lines.filter { it.key.id == id && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideLine(p: Polyline) {
|
||||
lines.filter { it.key == p && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllLinesInOwner(owner: String) {
|
||||
lines.filter { it.key.owner == owner && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllLinesInLevel(level: Level) {
|
||||
lines.filter { it.key.level == level && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllLines() {
|
||||
lines.filter { it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeLine(id: String) {
|
||||
synchronized(lines) {
|
||||
val keys = ArrayList<Polyline>()
|
||||
lines.filter { it.key.id == id }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
lines.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeLine(p: Polyline) {
|
||||
synchronized(lines) {
|
||||
val keys = ArrayList<Polyline>()
|
||||
lines.filter { it.key == p }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
lines.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeAllLinesInOwner(owner: String) {
|
||||
synchronized(lines) {
|
||||
val keys = ArrayList<Polyline>()
|
||||
lines.filter { it.key.owner == owner }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
lines.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeAllLinesInLevel(level: Level) {
|
||||
synchronized(lines) {
|
||||
val keys = ArrayList<Polyline>()
|
||||
lines.filter { it.key.level == level }.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
keys += it.key
|
||||
}
|
||||
keys.forEach {
|
||||
lines.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeAllLines() {
|
||||
synchronized(lines) {
|
||||
lines.onEach {
|
||||
try {
|
||||
it.value.remove()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
try {
|
||||
it.value.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}
|
||||
lines.clear()
|
||||
}
|
||||
}
|
||||
|
||||
override fun showAllLines() {
|
||||
lines.filter { !it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showAllLinesInOwner(owner: String) {
|
||||
lines.filter { !it.value.isVisible() && it.key.owner == owner }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showAllLinesInLevel(level: Level) {
|
||||
lines.filter { !it.value.isVisible() && it.key.level == level }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showLine(id: String) {
|
||||
lines.filter { it.key.id == id && !it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllPointsExceptIds(vararg ids: String) {
|
||||
points.filter { !ids.contains(it.key.id) && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideAllPointsExceptOwners(vararg owners: String) {
|
||||
points.filter { !owners.contains(it.key.owner) && it.value.isVisible() }.onEach {
|
||||
it.value.setVisible(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mogo.map.overlay.wrapper.line
|
||||
|
||||
import com.mogo.map.overlay.line.Polyline.Options
|
||||
import com.mogo.map.overlay.proxy.line.*
|
||||
import com.mogo.map.utils.ObjectUtils
|
||||
import com.zhidaoauto.map.sdk.open.poyline.*
|
||||
import java.util.concurrent.atomic.*
|
||||
|
||||
class AMapPolylineWrapper(private val id: String, private val delegate: Polyline): IMapPolylineOverlay {
|
||||
|
||||
private val isDestroyed by lazy { AtomicBoolean(false) }
|
||||
|
||||
private val isRemoved by lazy { AtomicBoolean(false) }
|
||||
|
||||
@Volatile
|
||||
private var onRemoveAction: ((id: String) -> Unit)? = null
|
||||
|
||||
override fun destroy() {
|
||||
if (isDestroyed.compareAndSet(false, true)) {
|
||||
try {
|
||||
delegate.destroy()
|
||||
} finally {
|
||||
onRemoveAction?.invoke(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun remove() {
|
||||
if (isRemoved.compareAndSet(false, true)) {
|
||||
try {
|
||||
delegate.remove()
|
||||
} finally {
|
||||
onRemoveAction?.invoke(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun setVisible(visible: Boolean) {
|
||||
if (isDestroyed.get() || isRemoved.get()) {
|
||||
return
|
||||
}
|
||||
delegate.setVisible(visible)
|
||||
}
|
||||
|
||||
override fun isDestroyed(): Boolean {
|
||||
return isDestroyed.get()
|
||||
}
|
||||
|
||||
override fun isVisible(): Boolean {
|
||||
return delegate.isVisible() ?: false
|
||||
}
|
||||
|
||||
override fun setToTop() {
|
||||
//没有对应的API
|
||||
}
|
||||
|
||||
override fun setUnTop() {
|
||||
//没有对应的API
|
||||
}
|
||||
|
||||
override fun setOptions(options: Options) {
|
||||
if (isDestroyed.get() || isRemoved.get()) {
|
||||
return
|
||||
}
|
||||
delegate.also {
|
||||
val option = ObjectUtils.fromMogo(options)
|
||||
if (option != null) {
|
||||
it.setOption(option)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRemove(action: (id: String) -> Unit) {
|
||||
onRemoveAction = action
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.mogo.map.overlay.wrapper.point
|
||||
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.map.overlay.point.Point.Options
|
||||
import com.mogo.map.overlay.proxy.point.*
|
||||
import com.mogo.map.utils.ObjectUtils
|
||||
import com.zhidaoauto.map.sdk.open.marker.*
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
class AMapPointWrapper(private val id: String, private val delegate: Marker): IMapPointOverlay {
|
||||
|
||||
private val isDestroyed by lazy { AtomicBoolean(false) }
|
||||
|
||||
private val isRemoved by lazy { AtomicBoolean(false) }
|
||||
|
||||
|
||||
@Volatile
|
||||
private var onRemoveAction: ((id: String) -> Unit)? = null
|
||||
|
||||
override fun destroy() {
|
||||
if (isDestroyed.compareAndSet(false, true)) {
|
||||
try {
|
||||
delegate.destroy()
|
||||
} finally {
|
||||
onRemoveAction?.invoke(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun remove() {
|
||||
if (isRemoved.compareAndSet(false, true)) {
|
||||
try {
|
||||
delegate.remove()
|
||||
} finally {
|
||||
onRemoveAction?.invoke(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun setVisible(visible: Boolean) {
|
||||
if (isDestroyed.get() || isRemoved.get()) {
|
||||
return
|
||||
}
|
||||
delegate.setVisible(visible)
|
||||
}
|
||||
|
||||
override fun isDestroyed(): Boolean {
|
||||
return isDestroyed.get()
|
||||
}
|
||||
|
||||
override fun isVisible(): Boolean {
|
||||
return delegate.isVisible()
|
||||
}
|
||||
|
||||
override fun setToTop() {
|
||||
if (isDestroyed.get() || isRemoved.get()) {
|
||||
return
|
||||
}
|
||||
delegate.setToTop()
|
||||
}
|
||||
|
||||
override fun setUnTop() {
|
||||
if (isDestroyed.get() || isRemoved.get()) {
|
||||
return
|
||||
}
|
||||
delegate.setUnTop()
|
||||
}
|
||||
|
||||
override fun setOptions(opt: Options) {
|
||||
if (isDestroyed.get() || isRemoved.get()) {
|
||||
return
|
||||
}
|
||||
delegate.setMarkerOptions(ObjectUtils.fromMogo(opt))
|
||||
}
|
||||
|
||||
override fun addDynamicAnchorPosition(point: MogoLatLng, angle: Float, duration: Long) {
|
||||
delegate.addDynamicAnchorPostion(LonLatPoint(point.lon, point.lat, angle.toDouble()), System.currentTimeMillis(), duration.toInt())
|
||||
}
|
||||
|
||||
override fun onRemove(action: (id: String) -> Unit) {
|
||||
onRemoveAction = action
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,8 @@ import android.view.View;
|
||||
|
||||
import com.mogo.eagle.core.data.map.CenterLine;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.map.overlay.line.Polyline;
|
||||
import com.mogo.map.overlay.point.Point;
|
||||
import com.mogo.map.uicontroller.MapCameraPosition;
|
||||
import com.zhidaoauto.map.sdk.open.camera.CameraPosition;
|
||||
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptor;
|
||||
@@ -33,7 +32,7 @@ import mogo.yycp.api.proto.SocketDownData;
|
||||
*/
|
||||
public class ObjectUtils {
|
||||
|
||||
public static MarkerOptions fromMogo(MogoMarkerOptions opt) {
|
||||
public static MarkerOptions fromMogo(Point.Options opt) {
|
||||
|
||||
if (opt == null) {
|
||||
return null;
|
||||
@@ -59,25 +58,26 @@ public class ObjectUtils {
|
||||
.rotateAngle(opt.getRotate())
|
||||
.setFlat(opt.isFlat())
|
||||
.visible(opt.isVisible())
|
||||
.infoWindowEnable(opt.isInifoWindowEnable())
|
||||
.infoWindowEnable(opt.isInfoWindowEnable())
|
||||
.scale(opt.getScale())
|
||||
.alpha(opt.getAlpha())
|
||||
.setInfoWindowOffset(opt.getOffsetX(), opt.getOffsetY())
|
||||
.zIndex(opt.getzIndex());
|
||||
.zIndex(opt.getLevel().getZIndex());
|
||||
|
||||
try {
|
||||
if (!TextUtils.isEmpty(opt.getAnchorColor())) {
|
||||
Color.parseColor(opt.getAnchorColor());
|
||||
markerOptions.anchorColor(opt.getAnchorColor());
|
||||
String anchorColor = opt.getAnchorColor();
|
||||
if (anchorColor != null && !TextUtils.isEmpty(anchorColor)) {
|
||||
Color.parseColor(anchorColor);
|
||||
markerOptions.anchorColor(anchorColor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
markerOptions.vrEnable(opt.is3DMode());
|
||||
if (!TextUtils.isEmpty(opt.getResName())) {
|
||||
markerOptions.setMarkerIconName(opt.getResName());
|
||||
String resName = opt.getResName();
|
||||
if (resName != null && !TextUtils.isEmpty(resName)) {
|
||||
markerOptions.setMarkerIconName(resName);
|
||||
} else {
|
||||
BitmapDescriptor descriptor = getBitmapDescriptorFromMogo(opt);
|
||||
BitmapDescriptor descriptor = getBitmapDescriptorFromMogo(opt.getIcon(), opt.getIconView());
|
||||
if (descriptor != null) {
|
||||
markerOptions.markerIcon(descriptor);
|
||||
}
|
||||
@@ -85,11 +85,13 @@ public class ObjectUtils {
|
||||
markerOptions.marker3DIcon(opt.getIcon3DRes());
|
||||
}
|
||||
}
|
||||
if (!TextUtils.isEmpty(opt.getTitle())) {
|
||||
markerOptions.title(opt.getTitle());
|
||||
String title = opt.getTitle();
|
||||
if (title != null && !TextUtils.isEmpty(title)) {
|
||||
markerOptions.title(title);
|
||||
}
|
||||
if (!TextUtils.isEmpty(opt.getSnippet())) {
|
||||
markerOptions.snippet(opt.getSnippet());
|
||||
String snippet = opt.getSnippet();
|
||||
if (snippet != null && !TextUtils.isEmpty(snippet)) {
|
||||
markerOptions.snippet(snippet);
|
||||
}
|
||||
return markerOptions;
|
||||
}
|
||||
@@ -107,7 +109,8 @@ public class ObjectUtils {
|
||||
markerOptions.setLat(trafficData.getLatitude());
|
||||
markerOptions.setLon(trafficData.getLongitude());
|
||||
markerOptions.setTime(Double.valueOf(trafficData.getSatelliteTime() * 1000).longValue());
|
||||
if(trafficData.getColor()!=null && !trafficData.getColor().isEmpty()){
|
||||
trafficData.getColor();
|
||||
if(!trafficData.getColor().isEmpty()){
|
||||
markerOptions.setColor(trafficData.getColor());
|
||||
}else{
|
||||
markerOptions.setColor("#00000000");
|
||||
@@ -138,68 +141,16 @@ public class ObjectUtils {
|
||||
return markerOptions;
|
||||
}
|
||||
|
||||
private static BitmapDescriptor getBitmapDescriptorFromMogo(MogoMarkerOptions options) {
|
||||
if (options == null) {
|
||||
return null;
|
||||
}
|
||||
Bitmap icon = options.getIcon();
|
||||
private static BitmapDescriptor getBitmapDescriptorFromMogo(Bitmap icon, View view) {
|
||||
if (icon != null) {
|
||||
return BitmapDescriptorFactory.INSTANCE.fromBitmap(icon);
|
||||
}
|
||||
View view = options.getIconView();
|
||||
if (view != null) {
|
||||
return BitmapDescriptorFactory.INSTANCE.fromView(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static MogoLocation fromLocation(com.zhidaoauto.map.sdk.open.location.MogoLocation aLocation) {
|
||||
if (aLocation == null) {
|
||||
return null;
|
||||
}
|
||||
MogoLocation location = new MogoLocation();
|
||||
|
||||
//agps 高德
|
||||
//agps_rtk 高德-高精
|
||||
if (aLocation.getProvider().isEmpty()) {
|
||||
location.setLocType(0);
|
||||
}
|
||||
if ("AGPS".equals(aLocation.getProvider())) {
|
||||
location.setLocType(1); // 定位类型为高德坐标(网路或者硬件定位)
|
||||
} else if ("AGPS_RTK".equals(aLocation.getProvider())) {
|
||||
location.setLocType(1000); // 定位类型为WGS84进行转译的坐标
|
||||
} else {
|
||||
location.setLocType(0);
|
||||
}
|
||||
location.setSatellite(4);
|
||||
location.setGnssSpeed(aLocation.getSpeed());
|
||||
location.setLatitude(aLocation.getLat());
|
||||
location.setLongitude(aLocation.getLon());
|
||||
location.setAltitude(aLocation.getAltitude());
|
||||
location.setHeading((float) aLocation.getHeading());
|
||||
location.setCityCode(aLocation.getCityCode());
|
||||
location.setCityName(aLocation.getCity());
|
||||
location.setProvider(aLocation.getProvider());
|
||||
location.setAddress(aLocation.getAddress());
|
||||
location.setDistrict(aLocation.getDistrict());
|
||||
location.setProvince(aLocation.getProvince());
|
||||
location.setAdCode(aLocation.getAdCode());
|
||||
// location.setAccuracy( aLocation.getAccuracy() );
|
||||
// location.setTime( aLocation.getTime() );
|
||||
// location.setLocationDetail( aLocation.getLocationDetail() );
|
||||
// location.setPoiName( aLocation.getPoiName() );
|
||||
// location.setAoiName( aLocation.getAoiName() );
|
||||
// location.setErrCode( aLocation.getErrorCode() );
|
||||
// location.setErrInfo( aLocation.getErrorInfo() );
|
||||
// location.setStreetNum( aLocation.getStreetNum() );
|
||||
// location.setDescription( aLocation.getDescription() );
|
||||
// location.setBuildingId( aLocation.getBuildingId() );
|
||||
// location.setFloor( aLocation.getFloor() );
|
||||
// location.setGpsAccuracyStatus( aLocation.getGpsAccuracyStatus() );
|
||||
return location;
|
||||
}
|
||||
|
||||
public static LonLatPoint fromMogo(MogoLatLng latLng) {
|
||||
if (latLng == null) {
|
||||
return null;
|
||||
@@ -214,12 +165,12 @@ public class ObjectUtils {
|
||||
return new MogoLatLng(point.getLatitude(), point.getLongitude());
|
||||
}
|
||||
|
||||
public static PolylineOptions fromMogo(MogoPolylineOptions options) {
|
||||
public static PolylineOptions fromMogo(Polyline.Options options) {
|
||||
if (options == null) {
|
||||
return null;
|
||||
}
|
||||
PolylineOptions target = new PolylineOptions();
|
||||
target.setGps(options.gps());
|
||||
target.setGps(options.isUseGps());
|
||||
if (options.getPoints() != null) {
|
||||
List<LonLatPoint> points = new ArrayList<>();
|
||||
for (MogoLatLng point : options.getPoints()) {
|
||||
@@ -228,20 +179,24 @@ public class ObjectUtils {
|
||||
target.lonLatPoints(points);
|
||||
}
|
||||
target.setLineWidth(options.getWidth());
|
||||
target.zIndex(options.getZIndex());
|
||||
target.dottedLine(options.isDottedLine());
|
||||
target.geodesic(options.isGeodesic());
|
||||
target.dottedLineType(options.getDottedLineType());
|
||||
target.zIndex(options.getLevel().getZIndex());
|
||||
target.setColor(options.getColor());
|
||||
target.useGradient(options.isGradient());
|
||||
target.useFacade(options.useFacade);
|
||||
if (options.maxIndex >= 0f) {
|
||||
target.maxIndex = options.maxIndex;
|
||||
target.useFacade(options.getUseFacade());
|
||||
target.setVisible(options.isVisible());
|
||||
if (options.getMaxIndex() >= 0f) {
|
||||
target.maxIndex = options.getMaxIndex();
|
||||
}
|
||||
if (options.getColorValues() != null) {
|
||||
target.colorValues(options.getColorValues());
|
||||
if (options.getColors() != null) {
|
||||
target.colorValues(options.getColors());
|
||||
}
|
||||
if (options.isBrightOn()) {
|
||||
if (options.isLightOn()) {
|
||||
target.isBright = true;
|
||||
target.brightColor = options.getBrightColor();
|
||||
target.brightSpeed = options.getBrightSpeed();
|
||||
target.brightColor = options.getLightColor();
|
||||
target.brightSpeed = options.getLightSpeed();
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user