Merge branch 'dev_minibus-d_230425_3.2.0' of gitlab.zhidaoauto.com:SCA/L4HA/AndroidApp/MoGoEagleEye into dev_minibus-d_230425_3.2.0
This commit is contained in:
@@ -1,17 +1,13 @@
|
||||
package com.mogo.map;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.center.CenterLine;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.map.overlay.line.Polyline;
|
||||
import com.mogo.map.overlay.point.Point;
|
||||
import com.mogo.map.overlay.proxy.line.IMapPolylineOverlay;
|
||||
import com.mogo.map.overlay.proxy.point.IMapPointOverlay;
|
||||
import com.mogo.map.road.RoadNameInfo;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo.yycp.api.proto.SocketDownData;
|
||||
|
||||
@@ -37,19 +33,9 @@ public interface IMogoMap {
|
||||
*/
|
||||
IMogoMapUIController getUIController();
|
||||
|
||||
/**
|
||||
* 在地图上添一个图片标记(marker)对象。
|
||||
*
|
||||
* @param tag 标识服务
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
IMogoMarker addMarker(String tag, MogoMarkerOptions options);
|
||||
IMapPointOverlay addPoint(Point.Options options);
|
||||
|
||||
/**
|
||||
* 清除所有marker
|
||||
*/
|
||||
void clearAllMarkers();
|
||||
IMapPolylineOverlay addLine(Polyline.Options options);
|
||||
|
||||
/**
|
||||
* 批量更新锚点位置
|
||||
@@ -80,16 +66,6 @@ public interface IMogoMap {
|
||||
*/
|
||||
void removeMarker(String uuidString);
|
||||
|
||||
/**
|
||||
* 在地图上添一组图片标记(marker)对象,并设置是否改变地图状态以至于所有的marker对象都在当前地图可视区域范围内显示。
|
||||
*
|
||||
* @param tag 标识服务
|
||||
* @param options
|
||||
* @param moveToCenter
|
||||
* @return
|
||||
*/
|
||||
ArrayList<IMogoMarker> addMarkers(String tag, ArrayList<MogoMarkerOptions> options, boolean moveToCenter);
|
||||
|
||||
/**
|
||||
* 从地图上删除所有的overlay(marker,circle,polyline 等对象)。
|
||||
*/
|
||||
@@ -136,14 +112,6 @@ public interface IMogoMap {
|
||||
*/
|
||||
float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK);
|
||||
|
||||
/**
|
||||
* 添加线段
|
||||
*
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
IMogoPolyline addPolyline(MogoPolylineOptions options);
|
||||
|
||||
/**
|
||||
* 获取行驶方向一定长度的中心线
|
||||
*
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.mogo.map.identity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo.yycp.api.proto.SocketDownData;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-25
|
||||
* <p>
|
||||
* 地图 marker 管理
|
||||
*/
|
||||
public interface IMogoIdentifyManager {
|
||||
|
||||
|
||||
/**
|
||||
* 要移除的感知数据uuid
|
||||
*
|
||||
* @param uuidString
|
||||
*/
|
||||
void removeMarker(String uuidString);
|
||||
|
||||
/**
|
||||
* 批量更新锚点位置
|
||||
*
|
||||
* @param optionsArrayList 锚点集合
|
||||
*/
|
||||
void updateBatchMarkerPosition(HashMap<String, MessagePad.TrackedObject> optionsArrayList);
|
||||
|
||||
/**
|
||||
* 批量更新锚点位置
|
||||
*
|
||||
* @param optionsArrayList 锚点集合
|
||||
*/
|
||||
void updateBatchAiMarkerPosition(HashMap<String, SocketDownData.CloudRoadDataProto> optionsArrayList);
|
||||
|
||||
/**
|
||||
* 添加感知使用到的3d模型
|
||||
*
|
||||
* @param type
|
||||
* @param modelRes
|
||||
*/
|
||||
String addPreVehicleModel(int type, int modelRes);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* 自定义 infowindow 适配器
|
||||
*/
|
||||
public interface IMogoInfoWindowAdapter {
|
||||
|
||||
/**
|
||||
* 获取infowindow的布局
|
||||
*
|
||||
* @param marker
|
||||
* @return
|
||||
*/
|
||||
View getInfoWindow( IMogoMarker marker );
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.marker.anim.OnMarkerAnimationListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-18
|
||||
* <p>
|
||||
* 地图 marker 抽象
|
||||
*/
|
||||
public interface IMogoMarker {
|
||||
|
||||
/**
|
||||
* 删除当前marker并销毁Marker的图片等资源
|
||||
*/
|
||||
void destroy();
|
||||
|
||||
/**
|
||||
* 删除当前marker。
|
||||
*/
|
||||
void remove();
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的透明度
|
||||
*
|
||||
* @param alpha
|
||||
*/
|
||||
void setAlpha( float alpha );
|
||||
|
||||
/**
|
||||
* 设置 Marker覆盖物的图标
|
||||
*
|
||||
* @param bitmap
|
||||
*/
|
||||
void setIcon( Bitmap bitmap );
|
||||
|
||||
/**
|
||||
* 设置 Marker 的图标集合,相同图案的 icon 的 marker 最好使用同一个 BitmapDescriptor 对象以节省内存空间。
|
||||
*
|
||||
* @param icons
|
||||
*/
|
||||
void setIcons( ArrayList< Bitmap > icons );
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的属性选项类 通过markerOption 给marker设置属性
|
||||
*
|
||||
* @param opt
|
||||
*/
|
||||
void setMarkerOptions( MogoMarkerOptions opt );
|
||||
|
||||
/**
|
||||
* 可以存储业务相关的数据
|
||||
*
|
||||
* @param object
|
||||
*/
|
||||
void setObject( Object object );
|
||||
|
||||
/**
|
||||
* @return 用户设置的 object 对象
|
||||
*/
|
||||
Object getObject();
|
||||
|
||||
/**
|
||||
* 设置位置
|
||||
*
|
||||
* @param lat
|
||||
* @param lng
|
||||
*/
|
||||
void setPosition( double lat, double lng );
|
||||
|
||||
/**
|
||||
* 获取坐标点
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
MogoLatLng getPosition();
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物图片旋转的角度,从正北开始,逆时针计算。
|
||||
*
|
||||
* @param rotate
|
||||
*/
|
||||
void setRotateAngle( float rotate );
|
||||
|
||||
/**
|
||||
* 设置Marker 覆盖物的标题。
|
||||
*
|
||||
* @param title
|
||||
*/
|
||||
void setTitle( String title );
|
||||
|
||||
/**
|
||||
* 设置当前marker在最上面。
|
||||
*/
|
||||
void setToTop();
|
||||
|
||||
/**
|
||||
* 设置 Marker 覆盖物的可见属性。
|
||||
*
|
||||
* @param visible
|
||||
*/
|
||||
void setVisible( boolean visible );
|
||||
|
||||
|
||||
/**
|
||||
* 设置点击事件
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
void setOnMarkerClickListener( IMogoMarkerClickListener listener );
|
||||
|
||||
/**
|
||||
* 获取点击事件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoMarkerClickListener getOnMarkerClickListener();
|
||||
|
||||
/**
|
||||
* 自定义 infowindow 样式接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoInfoWindowAdapter getInfoWindowAdapter();
|
||||
|
||||
/**
|
||||
* 是否被销毁
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isDestroyed();
|
||||
|
||||
/**
|
||||
* 设置marker的归属模块
|
||||
*
|
||||
* @param mOwner
|
||||
*/
|
||||
void setOwner( String mOwner );
|
||||
|
||||
/**
|
||||
* 获取marker的归属模块
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getOwner();
|
||||
|
||||
/**
|
||||
* Marker 配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
MogoMarkerOptions getMogoMarkerOptions();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 缩放动画
|
||||
*
|
||||
* @param fromX
|
||||
* @param toX
|
||||
* @param fromY
|
||||
* @param toY
|
||||
* @param duration
|
||||
* @param interpolator
|
||||
* @param listener
|
||||
*/
|
||||
void startScaleAnimation( float fromX,
|
||||
float toX,
|
||||
float fromY,
|
||||
float toY,
|
||||
int duration,
|
||||
Interpolator interpolator,
|
||||
OnMarkerAnimationListener listener );
|
||||
|
||||
/**
|
||||
* 是否是否可点击
|
||||
*
|
||||
* @param clickable
|
||||
*/
|
||||
void setClickable( boolean clickable );
|
||||
|
||||
|
||||
/**
|
||||
* 设置是否是gps
|
||||
*
|
||||
* @param isGps
|
||||
*/
|
||||
void setGps( boolean isGps );
|
||||
|
||||
/**
|
||||
* 设置3D车模颜色
|
||||
*
|
||||
* @param anchorColor
|
||||
*/
|
||||
default void setAnchorColor( String anchorColor ) {
|
||||
|
||||
}
|
||||
|
||||
default void addDynamicAnchorPosition( MogoLatLng latLng, float angle, long duration ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 marker 内部使用资源内容 md5
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default String getMarkerResName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-23
|
||||
* <p>
|
||||
* marker 点击事件
|
||||
*/
|
||||
public interface IMogoMarkerClickListener {
|
||||
|
||||
/**
|
||||
* 事件是否继续往下传递
|
||||
*
|
||||
* @param marker
|
||||
* @return true - 事件已经处理完毕不继续往下传,否则继续往下传
|
||||
*/
|
||||
default boolean onMarkerClicked(IMogoMarker marker){
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* 地图上静态Marker点击事件传递
|
||||
* @param marker
|
||||
* @return true - 事件已经处理完毕不继续往下传,否则继续往下传
|
||||
*/
|
||||
default boolean onStaticMarkerClicked(IMogoMarker marker){
|
||||
return false;
|
||||
};
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-23
|
||||
* <p>
|
||||
* 地图操作回调
|
||||
*/
|
||||
public interface IMogoMarkerClickListenerRegister {
|
||||
|
||||
/**
|
||||
* 注册marker回调,各业务模块不用关注
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
void registerMarkerClickListener(String tag, IMogoMarkerClickListener listener );
|
||||
|
||||
|
||||
/**
|
||||
* 注销marker回调,各业务模块不需要关注
|
||||
*/
|
||||
void unregisterMarkerClickListener(String tag);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-29
|
||||
* <p>
|
||||
* 动态变换 marker 样式接口
|
||||
*/
|
||||
public interface IMogoMarkerIconViewCreator {
|
||||
|
||||
/**
|
||||
* 返回自定义marker样式
|
||||
*
|
||||
* @param marker marker 的数据
|
||||
* @return
|
||||
*/
|
||||
View createView( IMogoMarker marker );
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
|
||||
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-25
|
||||
* <p>
|
||||
* 地图 marker 管理
|
||||
*/
|
||||
public interface IMogoMarkerManager {
|
||||
|
||||
/**
|
||||
* 添加marker
|
||||
*
|
||||
* @param tag 标识调用者
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
IMogoMarker addMarker(String tag, MogoMarkerOptions options);
|
||||
|
||||
/**
|
||||
* 添加多个marker
|
||||
*
|
||||
* @param tag 标识调用者
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
List<IMogoMarker> addMarkers(String tag, ArrayList<MogoMarkerOptions> options, boolean moveToCenter);
|
||||
|
||||
/**
|
||||
* 清除所有marker
|
||||
*/
|
||||
void clearAllMarker();
|
||||
|
||||
/**
|
||||
* 批量更新锚点位置
|
||||
*
|
||||
* @param optionsArrayList 锚点集合
|
||||
*/
|
||||
void updateBatchMarkerPosition(HashMap<String, MessagePad.TrackedObject> optionsArrayList);
|
||||
|
||||
/**
|
||||
* 批量更新锚点位置
|
||||
*
|
||||
* @param optionsArrayList 锚点集合
|
||||
*/
|
||||
void updateBatchAiMarkerPosition(HashMap<String, SocketDownData.CloudRoadDataProto> optionsArrayList);
|
||||
|
||||
/**
|
||||
* 添加感知使用到的3d模型
|
||||
*
|
||||
* @param type
|
||||
* @param modelRes
|
||||
*/
|
||||
String addPreVehicleModel(int type, int modelRes);
|
||||
|
||||
/**
|
||||
* 要移除的感知数据uuid
|
||||
*
|
||||
* @param uuidString
|
||||
*/
|
||||
void removeMarker(String uuidString);
|
||||
|
||||
/**
|
||||
* 移除某一个类型、某个模块的 markers
|
||||
*
|
||||
* @param tag
|
||||
*/
|
||||
void removeMarkers(String tag);
|
||||
|
||||
/**
|
||||
* 移除地图上添加的所有markers
|
||||
*/
|
||||
void removeMarkers();
|
||||
|
||||
/**
|
||||
* 显示地图上添加的所有markers
|
||||
*/
|
||||
void visibleAllMarkers();
|
||||
|
||||
/**
|
||||
* 隐藏地图上添加的所有markers
|
||||
*/
|
||||
void inVisibleAllMarkers();
|
||||
|
||||
/**
|
||||
* 隐藏除了某些类别的所有marker {@link MogoMarkerOptions Owner}
|
||||
*
|
||||
* @param owner
|
||||
*/
|
||||
void inVisibleWithoutMarkers(String... owner); //todo 后续需要把Owner类别统一起来,基类下沉,此接口为临时方案,应该设计为隐藏某一类元素
|
||||
|
||||
/**
|
||||
* 获取某种类型的全部marker。
|
||||
*
|
||||
* @param tag 业务类型
|
||||
* @return
|
||||
*/
|
||||
List<IMogoMarker> getMarkers(String tag);
|
||||
|
||||
/**
|
||||
* 获取所有类型的marker。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, List<IMogoMarker>> getAllMarkers();
|
||||
|
||||
/**
|
||||
* 仅保留指定类型的tag
|
||||
*
|
||||
* @param tag 需要保留的类型
|
||||
*/
|
||||
void removeMarkersExcept(String tag);
|
||||
|
||||
/**
|
||||
* 添加搜索路线
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param startPoint 起点
|
||||
* @param endPoint 终点
|
||||
* @param wayPoints 途经点
|
||||
*/
|
||||
void addRouteWay(Context context, MogoLatLng startPoint, MogoLatLng endPoint, List<MogoLatLng> wayPoints);
|
||||
|
||||
/**
|
||||
* 移除添加的导航预测路线
|
||||
*/
|
||||
void removeRouteWayOverlay();
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
public class MarkerType {
|
||||
|
||||
public static final String MAP_STATIC = "mapStatic";
|
||||
public static final String MAP_STATIC_TRAFFIC = "trafficcamera";
|
||||
}
|
||||
@@ -1,460 +0,0 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.location.Location;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.RawRes;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Observable;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-18
|
||||
* <p>
|
||||
* 地图marker
|
||||
*/
|
||||
public class MogoMarkerOptions extends Observable {
|
||||
|
||||
// marker 唯一标记
|
||||
private String uuid;
|
||||
private int markerType;
|
||||
private double latitude;
|
||||
private double longitude;
|
||||
// 设置 Marker覆盖物 的标题
|
||||
private String title;
|
||||
// 设置 Marker覆盖物的 文字描述
|
||||
private String snippet;
|
||||
// 设置Marker覆盖物的图标。
|
||||
private Bitmap icon;
|
||||
// 设置Marker覆盖物的动画帧图标列表,多张图片模拟gif的效果。
|
||||
private ArrayList< Bitmap > icons;
|
||||
// 设置多少帧刷新一次图片资源,Marker动画的间隔时间,值越小动画越快。
|
||||
private int period = 20;
|
||||
// 设置Marker覆盖物的图片旋转角度,从正北开始,逆时针计算。
|
||||
private float rotate;
|
||||
// 设置Marker覆盖物是否平贴地图。
|
||||
private boolean flat = false;
|
||||
// 设置Marker覆盖物是否可见。
|
||||
private boolean visible = true;
|
||||
// 设置Marker覆盖物的InfoWindow是否允许显示
|
||||
private boolean inifoWindowEnable = true;
|
||||
// 设置Marker覆盖物的透明度
|
||||
private float alpha = 1.0f;
|
||||
|
||||
// 设置Marker覆盖物的缩放
|
||||
private float scale = 1.0f;
|
||||
|
||||
// Marker覆盖物的坐标是否是Gps
|
||||
private boolean isGps = false;
|
||||
|
||||
// Marker覆盖物锚点在水平范围的比例。
|
||||
private float u = 0.5f;
|
||||
// Marker覆盖物锚点垂直范围的比例。
|
||||
private float v = 1f;
|
||||
|
||||
// 设置Marker覆盖物是否可拖拽。
|
||||
private boolean draggable = false;
|
||||
|
||||
// Marker覆盖物的InfoWindow相对X 轴的Marker的偏移
|
||||
private int offsetX = 0;
|
||||
// Marker覆盖物的InfoWindow相对Y 轴的Marker的偏移
|
||||
private int offsetY = 0;
|
||||
|
||||
// 设置Marker覆盖物 zIndex。
|
||||
private int zIndex = 0;
|
||||
// 自定义样式
|
||||
private View mIconView;
|
||||
// marker 归属模块
|
||||
private String mOwner;
|
||||
|
||||
private Object mObject;
|
||||
|
||||
/**
|
||||
* 是否加入marker管理
|
||||
*/
|
||||
private boolean mAutoManager = true;
|
||||
|
||||
private @RawRes
|
||||
int mIcon3DRes = 0;
|
||||
private String mAnchorColor;
|
||||
|
||||
private boolean mIs3DMode = false;
|
||||
|
||||
private boolean mIsControlAngle = false;
|
||||
|
||||
/**
|
||||
* 资源名称,便于缓存重复使用,和mIcon3DRes、mIconView、icon等冲突,需要县设置
|
||||
*/
|
||||
private String mResName;
|
||||
|
||||
/**
|
||||
* 吸附在车道上
|
||||
*/
|
||||
private boolean mMatchOnRoadSide = true;
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public int getMarkerType() {
|
||||
return markerType;
|
||||
}
|
||||
|
||||
public void setMarkerType(int markerType) {
|
||||
this.markerType = markerType;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions matchOnRoadSide(boolean matchOnRoadSide ) {
|
||||
this.mMatchOnRoadSide = matchOnRoadSide;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isMatchOnRoadSide() {
|
||||
return mMatchOnRoadSide;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions resName( String resName ) {
|
||||
this.mResName = resName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getResName() {
|
||||
return mResName;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions controlAngle( boolean controlAngle ) {
|
||||
this.mIsControlAngle = controlAngle;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isControlAngle() {
|
||||
return mIsControlAngle;
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions position( MogoLocation location ) {
|
||||
if ( location != null ) {
|
||||
latitude( location.getLatitude() );
|
||||
longitude( location.getLongitude() );
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions position( Location location ) {
|
||||
if ( location != null ) {
|
||||
latitude( location.getLatitude() );
|
||||
longitude( location.getLongitude() );
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions latitude( double latitude ) {
|
||||
this.latitude = latitude;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions longitude( double longitude ) {
|
||||
this.longitude = longitude;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions title( String title ) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions snippet( String snippet ) {
|
||||
this.snippet = snippet;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 优先使用icon作为marker资源
|
||||
*
|
||||
* @param icon
|
||||
* @return
|
||||
*/
|
||||
public MogoMarkerOptions icon( Bitmap icon ) {
|
||||
this.icon = icon;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions icons( ArrayList< Bitmap > icons ) {
|
||||
this.icons = icons;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions period( int period ) {
|
||||
this.period = period;
|
||||
if ( this.period < 1 ) {
|
||||
this.period = 1;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions rotate( float rotate ) {
|
||||
this.rotate = rotate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions flat( boolean flat ) {
|
||||
this.flat = flat;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions visible( boolean visible ) {
|
||||
this.visible = visible;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions inifoWindowEnable( boolean inifoWindowEnable ) {
|
||||
this.inifoWindowEnable = inifoWindowEnable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions alpha( float alpha ) {
|
||||
this.alpha = alpha;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions scale( float scale ) {
|
||||
this.scale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public MogoMarkerOptions gps( boolean gps ) {
|
||||
isGps = gps;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions anchor( float u, float v ) {
|
||||
this.u = u;
|
||||
this.v = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions draggable( boolean draggable ) {
|
||||
this.draggable = draggable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions setInfoWindowOffset( int offsetX, int offsetY ) {
|
||||
this.offsetX = offsetX;
|
||||
this.offsetY = offsetY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions zIndex( int zIndex ) {
|
||||
this.zIndex = zIndex;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions data(Object object ) {
|
||||
this.mObject = object;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义marker图层样式,优先使用 icon {@link #icon(Bitmap)}作为marker资源
|
||||
*
|
||||
* @param iconView
|
||||
* @return
|
||||
*/
|
||||
public MogoMarkerOptions icon( View iconView ) {
|
||||
this.mIconView = iconView;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions owner( String owner ) {
|
||||
this.mOwner = owner;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions icon3DRes( @RawRes int icon3DRes ) {
|
||||
this.mIcon3DRes = icon3DRes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions anchorColor( String anchorColor ) {
|
||||
this.mAnchorColor = anchorColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getSnippet() {
|
||||
return snippet;
|
||||
}
|
||||
|
||||
public Bitmap getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public ArrayList< Bitmap > getIcons() {
|
||||
return icons;
|
||||
}
|
||||
|
||||
public int getPeriod() {
|
||||
return period;
|
||||
}
|
||||
|
||||
public float getRotate() {
|
||||
return rotate;
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
return flat;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public boolean isInifoWindowEnable() {
|
||||
return inifoWindowEnable;
|
||||
}
|
||||
|
||||
public float getAlpha() {
|
||||
return alpha;
|
||||
}
|
||||
|
||||
public float getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
public boolean isGps() {
|
||||
return isGps;
|
||||
}
|
||||
|
||||
public float getU() {
|
||||
return u;
|
||||
}
|
||||
|
||||
public float getV() {
|
||||
return v;
|
||||
}
|
||||
|
||||
public boolean isDraggable() {
|
||||
return draggable;
|
||||
}
|
||||
|
||||
public int getOffsetX() {
|
||||
return offsetX;
|
||||
}
|
||||
|
||||
public int getOffsetY() {
|
||||
return offsetY;
|
||||
}
|
||||
|
||||
public int getzIndex() {
|
||||
return zIndex;
|
||||
}
|
||||
|
||||
public View getIconView() {
|
||||
return mIconView;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return mOwner;
|
||||
}
|
||||
|
||||
public Object getObject() {
|
||||
return mObject;
|
||||
}
|
||||
|
||||
public boolean isAutoManager() {
|
||||
return mAutoManager;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions autoManager( boolean autoManager ) {
|
||||
this.mAutoManager = autoManager;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getIcon3DRes() {
|
||||
return mIcon3DRes;
|
||||
}
|
||||
|
||||
public String getAnchorColor() {
|
||||
return mAnchorColor;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions setGps(boolean gps) {
|
||||
isGps = gps;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MogoMarkerOptions{" +
|
||||
"uuid='" + uuid + '\'' +
|
||||
", markerType=" + markerType +
|
||||
", latitude=" + latitude +
|
||||
", longitude=" + longitude +
|
||||
", title='" + title + '\'' +
|
||||
", snippet='" + snippet + '\'' +
|
||||
", icon=" + icon +
|
||||
", icons=" + icons +
|
||||
", period=" + period +
|
||||
", rotate=" + rotate +
|
||||
", flat=" + flat +
|
||||
", visible=" + visible +
|
||||
", inifoWindowEnable=" + inifoWindowEnable +
|
||||
", alpha=" + alpha +
|
||||
", scale=" + scale +
|
||||
", isGps=" + isGps +
|
||||
", u=" + u +
|
||||
", v=" + v +
|
||||
", draggable=" + draggable +
|
||||
", offsetX=" + offsetX +
|
||||
", offsetY=" + offsetY +
|
||||
", zIndex=" + zIndex +
|
||||
", mIconView=" + mIconView +
|
||||
", mOwner='" + mOwner + '\'' +
|
||||
", mObject=" + mObject +
|
||||
", mAutoManager=" + mAutoManager +
|
||||
", mIcon3DRes=" + mIcon3DRes +
|
||||
", mAnchorColor='" + mAnchorColor + '\'' +
|
||||
", mIs3DMode=" + mIs3DMode +
|
||||
", mIsControlAngle=" + mIsControlAngle +
|
||||
", mResName='" + mResName + '\'' +
|
||||
", mMatchOnRoadSide=" + mMatchOnRoadSide +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
package com.mogo.map.marker
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.text.TextUtils
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.function.Consumer
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
*
|
||||
*
|
||||
* 管理地图上的所有marker
|
||||
*/
|
||||
class MogoMarkersHandler private constructor() : IMogoMarkerClickListener,
|
||||
IMogoMarkerClickListenerRegister {
|
||||
|
||||
companion object {
|
||||
val mogoMarkersHandler by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
MogoMarkersHandler()
|
||||
}
|
||||
}
|
||||
|
||||
private val mMap: ConcurrentHashMap<String, IMogoMarkerClickListener> = ConcurrentHashMap()
|
||||
private val mServicesMarkers: MutableMap<String, MutableList<IMogoMarker>?> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
override fun registerMarkerClickListener(tag: String, listener: IMogoMarkerClickListener) {
|
||||
if (mMap.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
mMap[tag] = listener
|
||||
}
|
||||
|
||||
override fun unregisterMarkerClickListener(tag: String) {
|
||||
if (!mMap.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
mMap.remove(tag)
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Synchronized
|
||||
fun visibleAll() {
|
||||
mServicesMarkers.values.stream()
|
||||
.filter { mogoMarkerList: List<IMogoMarker>? -> mogoMarkerList != null && !mogoMarkerList.isEmpty() }
|
||||
.forEach { mogoMarkerList: List<IMogoMarker>? ->
|
||||
mogoMarkerList!!.forEach(
|
||||
Consumer { mogoMarker: IMogoMarker -> mogoMarker.setVisible(true) })
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Synchronized
|
||||
fun inVisibleAll() {
|
||||
mServicesMarkers.values.stream()
|
||||
.filter { mogoMarkerList: List<IMogoMarker>? -> mogoMarkerList != null && !mogoMarkerList.isEmpty() }
|
||||
.forEach { mogoMarkerList: List<IMogoMarker>? ->
|
||||
mogoMarkerList!!.forEach(
|
||||
Consumer { mogoMarker: IMogoMarker -> mogoMarker.setVisible(false) })
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Synchronized
|
||||
fun inVisibleMarkers(vararg owner: String?) {
|
||||
mServicesMarkers.values.stream()
|
||||
.filter { mogoMarkerList: List<IMogoMarker>? -> mogoMarkerList != null && !mogoMarkerList.isEmpty() }
|
||||
.forEach { mogoMarkerList: List<IMogoMarker>? ->
|
||||
mogoMarkerList!!.forEach(
|
||||
Consumer { mogoMarker: IMogoMarker ->
|
||||
if (TextUtils.isEmpty(mogoMarker.owner)) {
|
||||
mogoMarker.setVisible(false)
|
||||
}
|
||||
if (!Arrays.asList(*owner).contains(mogoMarker.owner)) {
|
||||
mogoMarker.setVisible(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun removeAll() {
|
||||
val mogoMarkers: Collection<List<IMogoMarker>?> = mServicesMarkers.values
|
||||
for (mogoMarkerList in mogoMarkers) {
|
||||
if (mogoMarkerList != null && !mogoMarkerList.isEmpty()) {
|
||||
for (mogoMarker in mogoMarkerList) {
|
||||
try {
|
||||
mogoMarker.destroy()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mServicesMarkers.clear()
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun remove(tag: String) {
|
||||
val mogoMarkerList = mServicesMarkers.remove(tag)
|
||||
if (mogoMarkerList != null && !mogoMarkerList.isEmpty()) {
|
||||
for (mogoMarker in mogoMarkerList) {
|
||||
try {
|
||||
mogoMarker.destroy()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
mogoMarkerList.clear()
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun getMarkers(tag: String): List<IMogoMarker>? {
|
||||
return mServicesMarkers[tag]
|
||||
}
|
||||
|
||||
@get:Synchronized
|
||||
val allMarkers: Map<String, MutableList<IMogoMarker>?>
|
||||
get() = mServicesMarkers
|
||||
|
||||
@Synchronized
|
||||
fun add(tag: String, marker: IMogoMarker?) {
|
||||
if (marker == null) {
|
||||
return
|
||||
}
|
||||
if (mServicesMarkers[tag] == null) {
|
||||
mServicesMarkers[tag] = ArrayList()
|
||||
}
|
||||
mServicesMarkers[tag]!!.add(marker)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun add(tag: String, markers: List<IMogoMarker>?) {
|
||||
if (markers == null || markers.isEmpty()) {
|
||||
return
|
||||
}
|
||||
if (mServicesMarkers[tag] == null) {
|
||||
mServicesMarkers[tag] = ArrayList()
|
||||
}
|
||||
mServicesMarkers[tag]!!.addAll(markers)
|
||||
}
|
||||
|
||||
override fun onMarkerClicked(marker: IMogoMarker): Boolean {
|
||||
val iMogoMarker = mMap[marker.owner]
|
||||
return iMogoMarker?.onMarkerClicked(marker) ?: false
|
||||
}
|
||||
|
||||
override fun onStaticMarkerClicked(marker: IMogoMarker): Boolean {
|
||||
val iMogoMarker = mMap[marker.owner]
|
||||
return iMogoMarker?.onStaticMarkerClicked(marker) ?: false
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tag 需要保留的类型
|
||||
*/
|
||||
fun deleteAllExcept(tag: String) {
|
||||
if (TextUtils.isEmpty(tag)) {
|
||||
return
|
||||
}
|
||||
val mogoMarkerList = mServicesMarkers.remove(tag)
|
||||
for (value in mServicesMarkers.values) {
|
||||
if (value != null && value.isNotEmpty()) {
|
||||
for (mogoMarker in value) {
|
||||
mogoMarker.destroy()
|
||||
}
|
||||
value.clear()
|
||||
}
|
||||
}
|
||||
mServicesMarkers[tag] = mogoMarkerList
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.mogo.map.marker.anim;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-22
|
||||
* <p>
|
||||
* marker 动画监听
|
||||
*/
|
||||
public interface OnMarkerAnimationListener {
|
||||
|
||||
default void onAnimStart() {
|
||||
}
|
||||
|
||||
default void onAnimEnd() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.mogo.map.overlay
|
||||
|
||||
import com.mogo.map.overlay.core.*
|
||||
import com.mogo.map.overlay.line.*
|
||||
import com.mogo.map.overlay.point.*
|
||||
import com.mogo.map.overlay.point.Point.Options as PointOptions
|
||||
import com.mogo.map.overlay.line.Polyline.Options as LineOptions
|
||||
|
||||
interface IMoGoOverlayManager {
|
||||
|
||||
fun showOrUpdatePoint(options: PointOptions): Point?
|
||||
|
||||
fun hidePoint(id: String)
|
||||
|
||||
fun hidePoint(p: Point)
|
||||
|
||||
fun hideAllPointsInOwner(owner: String)
|
||||
|
||||
fun hideAllPointsInLevel(level: Level)
|
||||
|
||||
fun hideAllPoints()
|
||||
|
||||
fun removePoint(id: String)
|
||||
|
||||
fun removePoint(p: Point)
|
||||
|
||||
fun removeAllPointsInOwner(owner: String)
|
||||
|
||||
fun removeAllPointsInLevel(level: Level)
|
||||
|
||||
fun removeAllPoints()
|
||||
|
||||
fun showAllPoints()
|
||||
|
||||
fun showAllPointsInOwner(owner: String)
|
||||
|
||||
fun showAllPointsInLevel(level: Level)
|
||||
|
||||
fun showPoint(id: String)
|
||||
|
||||
fun showOrUpdateLine(options: LineOptions): Polyline?
|
||||
|
||||
fun hideLine(id: String)
|
||||
|
||||
fun hideLine(p: Polyline)
|
||||
|
||||
fun hideAllLinesInOwner(owner: String)
|
||||
|
||||
fun hideAllLinesInLevel(level: Level)
|
||||
|
||||
fun hideAllLines()
|
||||
|
||||
fun removeLine(id: String)
|
||||
|
||||
fun removeLine(p: Polyline)
|
||||
|
||||
fun removeAllLinesInOwner(owner: String)
|
||||
|
||||
fun removeAllLinesInLevel(level: Level)
|
||||
|
||||
fun removeAllLines()
|
||||
|
||||
fun showAllLines()
|
||||
|
||||
fun showAllLinesInOwner(owner: String)
|
||||
|
||||
fun showAllLinesInLevel(level: Level)
|
||||
|
||||
fun showLine(id: String)
|
||||
|
||||
fun hideAllPointsExceptIds(vararg ids: String)
|
||||
|
||||
fun hideAllPointsExceptOwners(vararg owners: String)
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.mogo.map.overlay;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-10
|
||||
* <p>
|
||||
* 覆盖物
|
||||
*/
|
||||
public interface IMogoOverlayManager {
|
||||
|
||||
/**
|
||||
* 绘制线段
|
||||
*
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
IMogoPolyline addPolyline( MogoPolylineOptions options );
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
package com.mogo.map.overlay;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
|
||||
import com.mogo.map.IDestroyable;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-10
|
||||
* <p>
|
||||
* 线段
|
||||
*/
|
||||
public interface IMogoPolyline extends IDestroyable {
|
||||
|
||||
|
||||
/**
|
||||
* 是否已经销毁
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isDestroyed();
|
||||
|
||||
/**
|
||||
* 移除
|
||||
*/
|
||||
void remove();
|
||||
|
||||
/**
|
||||
* 获取ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* 设置绘制点数据
|
||||
*
|
||||
* @param lonLats
|
||||
*/
|
||||
void setPoints( List< MogoLatLng > lonLats );
|
||||
|
||||
/**
|
||||
* 获取点
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List< MogoLatLng > getPoints();
|
||||
|
||||
/**
|
||||
* 测地线
|
||||
*
|
||||
* @param draw
|
||||
*/
|
||||
void setGeodesic( boolean draw );
|
||||
|
||||
/**
|
||||
* 是否设置了测地线
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isGeodesic();
|
||||
|
||||
/**
|
||||
* 虚线
|
||||
*
|
||||
* @param dottedLine
|
||||
*/
|
||||
void setDottedLine( boolean dottedLine );
|
||||
|
||||
/**
|
||||
* 是否是虚线
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isDottedLine();
|
||||
|
||||
/**
|
||||
* 设置线宽
|
||||
*
|
||||
* @param width
|
||||
*/
|
||||
void setWidth( float width );
|
||||
|
||||
/**
|
||||
* 获取线宽
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
float getWidth();
|
||||
|
||||
/**
|
||||
* 设置线条颜色
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
void setColor( @ColorInt int color );
|
||||
|
||||
/**
|
||||
* 获取线条颜色
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ColorInt
|
||||
int getColor();
|
||||
|
||||
/**
|
||||
* 设置Z轴
|
||||
*/
|
||||
void setZIndex( float zIndex );
|
||||
|
||||
/**
|
||||
* 获取Z轴
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
float getZIndex();
|
||||
|
||||
/**
|
||||
* 设置显示/隐藏
|
||||
*/
|
||||
void setVisible( boolean visible );
|
||||
|
||||
/**
|
||||
* 是否可见
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isVisible();
|
||||
|
||||
/**
|
||||
* 设置透明度
|
||||
*
|
||||
* @param transparency
|
||||
*/
|
||||
void setTransparency( float transparency );
|
||||
|
||||
/**
|
||||
* 设置配置项
|
||||
*/
|
||||
void setOption( MogoPolylineOptions option );
|
||||
}
|
||||
@@ -1,288 +0,0 @@
|
||||
package com.mogo.map.overlay;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-10
|
||||
* <p>
|
||||
* 线段属性
|
||||
*/
|
||||
public class MogoPolylineOptions {
|
||||
|
||||
public boolean useFacade = false;
|
||||
public float maxIndex = Float.MIN_VALUE;
|
||||
private List<MogoLatLng> mPoints;
|
||||
private float mWidth = 10.0F;
|
||||
private int mColor = Color.BLACK;
|
||||
private float mZIndex = 0.0F;
|
||||
private boolean mIsVisible = true;
|
||||
private boolean mIsGeodesic = false;
|
||||
private boolean mIsDottedLine = false;
|
||||
private boolean mIsGradient = false;
|
||||
private float mTransparency = 1.0F;
|
||||
private boolean mIsAboveMaskLayer = false;
|
||||
private boolean mIsPointsUpdated = false;
|
||||
private boolean mGps = false;
|
||||
private List<Integer> mColorValues;
|
||||
|
||||
private float brightSpeed = Float.MIN_VALUE;
|
||||
|
||||
private int brightColor = -1;
|
||||
|
||||
private boolean isBrightOn = false;
|
||||
|
||||
public MogoPolylineOptions() {
|
||||
this.mPoints = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置顶点
|
||||
*
|
||||
* @param points
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions points(List<MogoLatLng> points) {
|
||||
this.mPoints.clear();
|
||||
this.mPoints.addAll(points);
|
||||
this.mIsPointsUpdated = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加顶点到集合最后
|
||||
*
|
||||
* @param points
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions add(MogoLatLng... points) {
|
||||
if (points != null) {
|
||||
this.mPoints.addAll(Arrays.asList(points));
|
||||
this.mIsPointsUpdated = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions add(double lon, double lat) {
|
||||
this.mPoints.add(new MogoLatLng(lat, lon));
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions add(MogoLocation location) {
|
||||
if (location != null) {
|
||||
this.mPoints.add(new MogoLatLng(location.getLatitude(), location.getLongitude()));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置线宽
|
||||
*/
|
||||
public MogoPolylineOptions width(float width) {
|
||||
this.mWidth = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置线的颜色
|
||||
*
|
||||
* @param color
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions color(@ColorInt int color) {
|
||||
this.mColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置Z轴的值
|
||||
*
|
||||
* @param zIndex
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions zIndex(float zIndex) {
|
||||
this.mZIndex = zIndex;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否可见
|
||||
*
|
||||
* @param isVisible
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions visible(boolean isVisible) {
|
||||
this.mIsVisible = isVisible;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否绘制测地线
|
||||
*
|
||||
* @param isGeodesic
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions geodesic(boolean isGeodesic) {
|
||||
this.mIsGeodesic = isGeodesic;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是虚线
|
||||
*
|
||||
* @param isDottedLine
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions dottedLine(boolean isDottedLine) {
|
||||
this.mIsDottedLine = isDottedLine;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否使用渐变色
|
||||
*
|
||||
* @param isGradient
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions useGradient(boolean isGradient) {
|
||||
this.mIsGradient = isGradient;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions maxIndex(float maxIndex) {
|
||||
this.maxIndex = maxIndex;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置透明度
|
||||
*
|
||||
* @param transparency
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions transparency(float transparency) {
|
||||
this.mTransparency = transparency;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions brightSpeed(float speed) {
|
||||
this.brightSpeed = speed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions openBright(boolean on) {
|
||||
this.isBrightOn = on;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions brightColor(int color) {
|
||||
this.brightColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions useFacade(boolean useFacade) {
|
||||
this.useFacade = useFacade;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param isAboveMaskLayer
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions aboveMaskLayer(boolean isAboveMaskLayer) {
|
||||
this.mIsAboveMaskLayer = isAboveMaskLayer;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param colors
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions colorValues(List<Integer> colors) {
|
||||
mColorValues = colors;
|
||||
return this;
|
||||
}
|
||||
public boolean gps() {
|
||||
return mGps;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions setGps(boolean gps) {
|
||||
mGps = gps;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<MogoLatLng> getPoints() {
|
||||
return mPoints;
|
||||
}
|
||||
|
||||
public float getWidth() {
|
||||
return mWidth;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return mColor;
|
||||
}
|
||||
|
||||
public float getZIndex() {
|
||||
return mZIndex;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return mIsVisible;
|
||||
}
|
||||
|
||||
public boolean isGeodesic() {
|
||||
return mIsGeodesic;
|
||||
}
|
||||
|
||||
public boolean isDottedLine() {
|
||||
return mIsDottedLine;
|
||||
}
|
||||
|
||||
public boolean isGradient() {
|
||||
return mIsGradient;
|
||||
}
|
||||
|
||||
public boolean useFacade() {
|
||||
return useFacade;
|
||||
}
|
||||
|
||||
|
||||
public float getTransparency() {
|
||||
return mTransparency;
|
||||
}
|
||||
|
||||
public boolean isAboveMaskLayer() {
|
||||
return mIsAboveMaskLayer;
|
||||
}
|
||||
|
||||
public boolean isPointsUpdated() {
|
||||
return mIsPointsUpdated;
|
||||
}
|
||||
|
||||
public float getBrightSpeed() {
|
||||
return brightSpeed;
|
||||
}
|
||||
|
||||
public boolean isBrightOn() {
|
||||
return isBrightOn;
|
||||
}
|
||||
|
||||
public int getBrightColor() {
|
||||
return brightColor;
|
||||
}
|
||||
|
||||
public List<Integer> getColorValues() {
|
||||
return mColorValues;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mogo.map.overlay.core
|
||||
|
||||
enum class Level(val zIndex: Int) {
|
||||
|
||||
|
||||
DEFAULT(10),
|
||||
|
||||
/**
|
||||
* 地图上Marker覆盖物
|
||||
*/
|
||||
MAP_MARKER(100),
|
||||
|
||||
/**
|
||||
* 车道中心线
|
||||
*/
|
||||
ROAD_CENTER_LINE(40000),
|
||||
|
||||
/**
|
||||
* 前车引导线
|
||||
*/
|
||||
GUIDE_ROUTE_LINE(75000),
|
||||
|
||||
|
||||
/**
|
||||
* 道路围栏区域绘制
|
||||
*/
|
||||
MAP_POLYGON(76000)
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.mogo.map.overlay.line
|
||||
|
||||
import android.graphics.*
|
||||
import android.text.TextUtils
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.map.overlay.core.*
|
||||
import com.mogo.map.overlay.proxy.line.*
|
||||
import java.util.UUID
|
||||
|
||||
data class Polyline(val id: String, val owner: String, val level: Level, val options: Options) {
|
||||
|
||||
@Volatile
|
||||
var delegate: IMapPolylineOverlay? = null
|
||||
|
||||
class Options private constructor(private val builder: Builder) {
|
||||
|
||||
val id: String = builder.id ?: throw AssertionError("id must not be null.")
|
||||
|
||||
val owner: String = builder.owner
|
||||
|
||||
val level: Level = builder.level
|
||||
|
||||
val useFacade: Boolean = builder.useFacade
|
||||
|
||||
val maxIndex: Float = builder.maxIndex
|
||||
|
||||
val points: List<MogoLatLng>? = builder.points
|
||||
|
||||
val width = builder.width
|
||||
|
||||
val color: Int = builder.color
|
||||
|
||||
val isVisible = builder.isVisible
|
||||
|
||||
val isGeodesic = builder.isGeodesic
|
||||
|
||||
val isDottedLine = builder.isDottedLine
|
||||
|
||||
val dottedLineType = builder.dottedLineType
|
||||
|
||||
val isGradient = builder.isGradient
|
||||
|
||||
val alpha = builder.alpha
|
||||
|
||||
val isUseGps = builder.isUseGps
|
||||
|
||||
val colors: List<Int>? = builder.colors
|
||||
|
||||
val isLightOn: Boolean = builder.isLightOn
|
||||
|
||||
val lightColor: Int = builder.lightColor
|
||||
|
||||
val lightSpeed: Float = builder.lightSpeed
|
||||
|
||||
fun builder(): Builder {
|
||||
return builder
|
||||
}
|
||||
|
||||
class Builder(val owner: String, val level: Level) {
|
||||
|
||||
internal var id: String? = null
|
||||
|
||||
internal var useFacade: Boolean = false
|
||||
|
||||
internal var maxIndex: Float = Float.MIN_VALUE
|
||||
|
||||
internal var points: List<MogoLatLng>? = null
|
||||
|
||||
internal var width = 10.0f
|
||||
|
||||
internal var color: Int = Color.BLACK
|
||||
|
||||
internal var isVisible = true
|
||||
|
||||
internal var isGeodesic = false
|
||||
|
||||
internal var isDottedLine = false
|
||||
|
||||
internal var dottedLineType = -1
|
||||
|
||||
internal var isGradient = false
|
||||
|
||||
internal var alpha = 1.0f
|
||||
|
||||
internal var isUseGps = false
|
||||
|
||||
internal var colors: List<Int>? = null
|
||||
|
||||
internal var isLightOn: Boolean = false
|
||||
|
||||
internal var lightColor: Int = Color.WHITE
|
||||
|
||||
internal var lightSpeed: Float = 0f
|
||||
|
||||
fun setId(id: String) = apply {
|
||||
this.id = id
|
||||
}
|
||||
|
||||
fun points(points: List<MogoLatLng>) = apply {
|
||||
this.points = points
|
||||
}
|
||||
|
||||
fun colors(colors: List<Int>) = apply {
|
||||
this.colors = colors
|
||||
}
|
||||
|
||||
fun color(color: Int) = apply {
|
||||
this.color = color
|
||||
}
|
||||
|
||||
fun setVisible(visible: Boolean) = apply {
|
||||
this.isVisible = visible
|
||||
}
|
||||
|
||||
fun setWidth(width: Float) = apply {
|
||||
this.width = width
|
||||
}
|
||||
|
||||
fun setMaxIndex(maxIndex: Float) = apply {
|
||||
this.maxIndex = maxIndex
|
||||
}
|
||||
|
||||
fun useFacade(facade: Boolean) = apply {
|
||||
this.useFacade = facade
|
||||
}
|
||||
|
||||
fun setGeodesic(isGeodesic: Boolean) = apply {
|
||||
this.isGeodesic = isGeodesic
|
||||
}
|
||||
|
||||
fun setIsDottedLine(isDottedLine: Boolean) = apply {
|
||||
this.isDottedLine = isDottedLine
|
||||
}
|
||||
|
||||
fun setDottedLineType(type: Int) = apply {
|
||||
this.dottedLineType = type
|
||||
}
|
||||
|
||||
fun setIsGradient(isGradient: Boolean) = apply {
|
||||
this.isGradient = isGradient
|
||||
}
|
||||
|
||||
fun setAlpha(alpha: Float) = apply {
|
||||
this.alpha = alpha
|
||||
}
|
||||
|
||||
fun setUseGps(isUseGps: Boolean) = apply {
|
||||
this.isUseGps = isUseGps
|
||||
}
|
||||
|
||||
fun setLightOn(isLightOn: Boolean) = apply {
|
||||
this.isLightOn = isLightOn
|
||||
}
|
||||
|
||||
fun setLightColor(color: Int) = apply {
|
||||
this.lightColor = color
|
||||
}
|
||||
|
||||
fun setLightSpeed(speed: Float) = apply {
|
||||
this.lightSpeed = speed
|
||||
}
|
||||
|
||||
fun build(): Options {
|
||||
if (TextUtils.isEmpty(id)) {
|
||||
id = UUID.randomUUID().toString()
|
||||
}
|
||||
if (TextUtils.isEmpty(id)) {
|
||||
throw AssertionError("id must not be null.")
|
||||
}
|
||||
return Options(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Polyline
|
||||
|
||||
if (id != other.id) return false
|
||||
if (owner != other.owner) return false
|
||||
if (level != other.level) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = id.hashCode()
|
||||
result = 31 * result + owner.hashCode()
|
||||
result = 31 * result + level.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,448 @@
|
||||
package com.mogo.map.overlay.point
|
||||
|
||||
import android.graphics.*
|
||||
import android.text.TextUtils
|
||||
import android.view.*
|
||||
import androidx.annotation.*
|
||||
import com.mogo.map.overlay.core.*
|
||||
import com.mogo.map.overlay.proxy.point.*
|
||||
import java.util.*
|
||||
|
||||
data class Point(val id: String, val owner: String, val level: Level, val option: Options) {
|
||||
|
||||
@Volatile
|
||||
var delegate: IMapPointOverlay? = null
|
||||
|
||||
/**
|
||||
*
|
||||
* 地图上绘制点相关的参数
|
||||
*/
|
||||
class Options private constructor(private val builder: Builder){
|
||||
|
||||
/**
|
||||
* 唯一标识,可以通过此标识,操作对点的显示和隐藏
|
||||
*/
|
||||
val id: String = builder.id ?: throw AssertionError("id must not be null")
|
||||
|
||||
/**
|
||||
* 当前地图覆盖物所在level(zIndex值在此存储)
|
||||
*/
|
||||
val level: Level = builder.level
|
||||
|
||||
/**
|
||||
* 当前地图覆盖物所属的业务类型
|
||||
*/
|
||||
val owner: String = builder.owner
|
||||
|
||||
/**
|
||||
* 绘制点的纬度
|
||||
*/
|
||||
val latitude: Double = builder.latitude ?: 0.0
|
||||
|
||||
/**
|
||||
* 绘制点的经度
|
||||
*/
|
||||
val longitude: Double = builder.longitude ?: 0.0
|
||||
|
||||
/**
|
||||
* 3D模型
|
||||
*/
|
||||
@RawRes
|
||||
val icon3DRes: Int = builder.icon3DRes
|
||||
|
||||
/**
|
||||
* 自定义样式
|
||||
*/
|
||||
val iconView: View? = builder.iconView
|
||||
|
||||
/**
|
||||
* 指定覆盖物的颜色
|
||||
*/
|
||||
val anchorColor: String? = builder.anchorColor
|
||||
|
||||
/**
|
||||
* 文字标题
|
||||
*/
|
||||
val title: String? = builder.title
|
||||
|
||||
/**
|
||||
* 文字描述
|
||||
*/
|
||||
val snippet: String? = builder.snippet
|
||||
|
||||
/**
|
||||
* 图标对应的Bitmap对象
|
||||
*/
|
||||
val icon: Bitmap? = builder.icon
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的动画帧图标列表,多张图片模拟gif的效果
|
||||
*/
|
||||
val icons: ArrayList<Bitmap>? = builder.icons
|
||||
|
||||
/**
|
||||
* 设置多少帧刷新一次图片资源,Marker动画的间隔时间,值越小动画越快
|
||||
*/
|
||||
val period = builder.period
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的图片旋转角度,从正北开始,逆时针计算
|
||||
*/
|
||||
val rotate = builder.rotate
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物是否平贴地图
|
||||
*/
|
||||
val isFlat = builder.isFlat
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物是否可见
|
||||
*/
|
||||
val isVisible = builder.isVisible
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的InfoWindow是否允许显示
|
||||
*/
|
||||
val isInfoWindowEnable = builder.isInfoWindowEnable
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的透明度
|
||||
*/
|
||||
val alpha = builder.alpha
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的透明度
|
||||
*/
|
||||
val scale = builder.scale
|
||||
|
||||
/**
|
||||
* Marker覆盖物的坐标是否是Gps
|
||||
*/
|
||||
val isGps = builder.isGps
|
||||
|
||||
/**
|
||||
* Marker覆盖物锚点在水平范围的比例
|
||||
*/
|
||||
val u = builder.u
|
||||
|
||||
/**
|
||||
* Marker覆盖物锚点垂直范围的比例
|
||||
*/
|
||||
val v = builder.v
|
||||
|
||||
/**
|
||||
* 是否是3D模型
|
||||
*/
|
||||
val is3DMode: Boolean = builder.is3DMode
|
||||
|
||||
/**
|
||||
* 是否控制角度
|
||||
*/
|
||||
val isControlAngle = builder.isControlAngle
|
||||
|
||||
/**
|
||||
* 资源名称,便于缓存重复使用,和mIcon3DRes、mIconView、icon等冲突,需要县设置
|
||||
*/
|
||||
val resName: String? = builder.resName
|
||||
|
||||
/**
|
||||
* 是否切换到当前marker所在的视角
|
||||
*/
|
||||
val moveToCenter: Boolean = builder.moveToCenter
|
||||
|
||||
fun builder(): Builder {
|
||||
return builder
|
||||
}
|
||||
|
||||
class Builder(val owner: String,val level: Level){
|
||||
|
||||
/**
|
||||
* 唯一标识,可以通过此标识,操作对点的显示和隐藏
|
||||
*/
|
||||
internal var id: String? = null
|
||||
|
||||
/**
|
||||
* 绘制点的纬度
|
||||
*/
|
||||
internal var latitude: Double? = null
|
||||
|
||||
/**
|
||||
* 绘制点的经度
|
||||
*/
|
||||
internal var longitude: Double? = null
|
||||
|
||||
/**
|
||||
* 3D模型
|
||||
*/
|
||||
@RawRes
|
||||
internal var icon3DRes = 0
|
||||
|
||||
|
||||
/**
|
||||
* 自定义样式
|
||||
*/
|
||||
internal var iconView: View? = null
|
||||
|
||||
/**
|
||||
* 指定覆盖物的颜色
|
||||
*/
|
||||
internal var anchorColor: String? = null
|
||||
|
||||
/**
|
||||
* 文字标题
|
||||
*/
|
||||
internal var title: String? = null
|
||||
|
||||
/**
|
||||
* 文字描述
|
||||
*/
|
||||
internal var snippet: String? = null
|
||||
|
||||
/**
|
||||
* 图标对应的Bitmap对象
|
||||
*/
|
||||
internal var icon: Bitmap? = null
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的动画帧图标列表,多张图片模拟gif的效果
|
||||
*/
|
||||
internal var icons: ArrayList<Bitmap>? = null
|
||||
|
||||
/**
|
||||
* 设置多少帧刷新一次图片资源,Marker动画的间隔时间,值越小动画越快
|
||||
*/
|
||||
internal var period = 0
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的图片旋转角度,从正北开始,逆时针计算
|
||||
*/
|
||||
internal var rotate = 0f
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物是否平贴地图
|
||||
*/
|
||||
internal var isFlat = false
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物是否可见
|
||||
*/
|
||||
internal var isVisible = true
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的InfoWindow是否允许显示
|
||||
*/
|
||||
internal var isInfoWindowEnable = true
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的透明度
|
||||
*/
|
||||
internal var alpha = 1.0f
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的透明度
|
||||
*/
|
||||
internal var scale = 1.0f
|
||||
|
||||
/**
|
||||
* Marker覆盖物的坐标是否是Gps
|
||||
*/
|
||||
internal var isGps = false
|
||||
|
||||
/**
|
||||
* Marker覆盖物锚点在水平范围的比例
|
||||
*/
|
||||
internal var u = 0.5f
|
||||
|
||||
/**
|
||||
* Marker覆盖物锚点垂直范围的比例
|
||||
*/
|
||||
internal var v = 0.5f
|
||||
|
||||
|
||||
/**
|
||||
* 是否是3D模型
|
||||
*/
|
||||
internal var is3DMode: Boolean = false
|
||||
|
||||
/**
|
||||
* 是否控制角度
|
||||
*/
|
||||
internal var isControlAngle = false
|
||||
|
||||
/**
|
||||
* 资源名称,便于缓存重复使用,和mIcon3DRes、mIconView、icon等冲突,需要县设置
|
||||
*/
|
||||
internal var resName: String? = null
|
||||
|
||||
|
||||
/**
|
||||
* 是否切换到当前marker所在的视角
|
||||
*/
|
||||
internal var moveToCenter: Boolean = true
|
||||
|
||||
fun setId(id: String) = apply {
|
||||
this.id = id
|
||||
}
|
||||
|
||||
fun resName(resName: String?) = apply {
|
||||
this.resName = resName
|
||||
}
|
||||
|
||||
fun controlAngle(controlAngle: Boolean) = apply {
|
||||
isControlAngle = controlAngle
|
||||
}
|
||||
|
||||
fun set3DMode(is3DMode: Boolean) = apply {
|
||||
this.is3DMode = is3DMode
|
||||
}
|
||||
|
||||
fun latitude(latitude: Double) = apply {
|
||||
this.latitude = latitude
|
||||
}
|
||||
|
||||
fun longitude(longitude: Double) = apply {
|
||||
this.longitude = longitude
|
||||
}
|
||||
|
||||
/**
|
||||
* 优先使用icon作为marker资源
|
||||
* @param icon
|
||||
* @return
|
||||
*/
|
||||
fun icon(icon: Bitmap?) = apply {
|
||||
this.icon = icon
|
||||
}
|
||||
|
||||
/**
|
||||
* 帧动画对应的图片序列
|
||||
*/
|
||||
fun icons(icons: ArrayList<Bitmap>?) = apply {
|
||||
this.icons = icons
|
||||
}
|
||||
|
||||
/**
|
||||
* 帧动画执行完成一次需要的时长,时间越短,帧动画越快
|
||||
*/
|
||||
fun period(period: Int) = apply {
|
||||
this.period = period
|
||||
if (this.period < 1) {
|
||||
this.period = 1
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* marker对应的资源的,旋转角度,正北方为0度,逆时针计算
|
||||
*/
|
||||
fun rotate(rotate: Float) = apply {
|
||||
this.rotate = rotate
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否平铺在地图上
|
||||
*/
|
||||
fun flat(flat: Boolean) = apply {
|
||||
isFlat = flat
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可见
|
||||
*/
|
||||
fun visible(visible: Boolean) = apply {
|
||||
isVisible = visible
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置地图覆盖物的透明度
|
||||
*/
|
||||
fun alpha(alpha: Float) = apply {
|
||||
this.alpha = alpha
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置地图覆盖物的缩放比例
|
||||
*/
|
||||
fun scale(scale: Float) = apply {
|
||||
this.scale = scale
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否使用GPS坐标
|
||||
*/
|
||||
fun isUseGps(gps: Boolean) = apply {
|
||||
this.isGps = gps
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置地图覆盖物锚点在水平和垂直方向的比例
|
||||
*/
|
||||
fun anchor(u: Float, v: Float) = apply {
|
||||
this.u = u
|
||||
this.v = v
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义marker图层样式,优先使用 icon [.icon]作为marker资源
|
||||
*
|
||||
* @param iconView
|
||||
* @return
|
||||
*/
|
||||
fun icon(iconView: View?) = apply {
|
||||
this.iconView = iconView
|
||||
}
|
||||
|
||||
/**
|
||||
* 3D模型对应的资源
|
||||
*/
|
||||
fun icon3DRes(@RawRes icon3DRes: Int) = apply {
|
||||
this.icon3DRes = icon3DRes
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置地图覆盖物的颜色
|
||||
*/
|
||||
fun anchorColor(anchorColor: String?) = apply {
|
||||
this.anchorColor = anchorColor
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否切换到当前marker所在的视角
|
||||
*/
|
||||
fun moveToCenter(flag: Boolean) = apply {
|
||||
this.moveToCenter = flag
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建Options对象
|
||||
*/
|
||||
fun build(): Options {
|
||||
if (TextUtils.isEmpty(id)) {
|
||||
id = UUID.randomUUID().toString()
|
||||
}
|
||||
if (TextUtils.isEmpty(id)) {
|
||||
throw AssertionError("id must not be null.")
|
||||
}
|
||||
return Options(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Point
|
||||
|
||||
if (id != other.id) return false
|
||||
if (owner != other.owner) return false
|
||||
if (level != other.level) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = id.hashCode()
|
||||
result = 31 * result + owner.hashCode()
|
||||
result = 31 * result + level.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.mogo.map.overlay.proxy
|
||||
|
||||
|
||||
interface IMapOverlay {
|
||||
|
||||
/**
|
||||
* 删除当前marker并销毁Marker的图片等资源
|
||||
*/
|
||||
fun destroy()
|
||||
|
||||
/**
|
||||
* 删除当前marker。
|
||||
*/
|
||||
fun remove()
|
||||
|
||||
/**
|
||||
* 设置 Marker 覆盖物的可见属性。
|
||||
*
|
||||
* @param visible
|
||||
*/
|
||||
fun setVisible(visible: Boolean)
|
||||
|
||||
/**
|
||||
* 是否已销毁
|
||||
*/
|
||||
fun isDestroyed(): Boolean
|
||||
|
||||
/**
|
||||
* 是否可见
|
||||
*/
|
||||
fun isVisible(): Boolean
|
||||
|
||||
|
||||
/**
|
||||
* 设置当前marker在最上面。
|
||||
*/
|
||||
fun setToTop()
|
||||
|
||||
/**
|
||||
* 取消当前marker在最上面
|
||||
*/
|
||||
fun setUnTop()
|
||||
|
||||
|
||||
fun onRemove(action: (id: String) -> Unit)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mogo.map.overlay.proxy.line
|
||||
|
||||
import com.mogo.map.overlay.line.*
|
||||
import com.mogo.map.overlay.proxy.*
|
||||
|
||||
interface IMapPolylineOverlay: IMapOverlay {
|
||||
|
||||
fun setOptions(options: Polyline.Options)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mogo.map.overlay.proxy.point
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.map.overlay.point.Point.Options
|
||||
import com.mogo.map.overlay.proxy.*
|
||||
|
||||
interface IMapPointOverlay: IMapOverlay {
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物的属性选项类 通过markerOption 给marker设置属性
|
||||
*
|
||||
* @param opt
|
||||
*/
|
||||
fun setOptions(opt: Options)
|
||||
|
||||
|
||||
fun addDynamicAnchorPosition(point: MogoLatLng, angle: Float, duration: Long)
|
||||
}
|
||||
@@ -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