[3.4.0-map-sdk] code style
This commit is contained in:
@@ -132,7 +132,7 @@ object ConfigStartUp {
|
||||
}
|
||||
|
||||
val mapParams = MapParams.init()
|
||||
mapParams.setDebugMode(true)
|
||||
mapParams.setDebugMode(false)
|
||||
// 1-使用本地地图数据,0-使用在线地图数据
|
||||
// .setDataFileSource(1)
|
||||
.setIsRecordLogs(false)
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.opengl.GLException
|
||||
import android.opengl.GLSurfaceView
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.Message
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
@@ -49,7 +50,10 @@ import java.util.concurrent.atomic.AtomicBoolean
|
||||
import javax.microedition.khronos.egl.EGL10
|
||||
import javax.microedition.khronos.egl.EGLConfig
|
||||
import javax.microedition.khronos.opengles.GL10
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.math.acos
|
||||
import kotlin.math.sqrt
|
||||
|
||||
class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, private val mILockLocation: ILockLocation) :
|
||||
GLSurfaceView(context), GLSurfaceView.Renderer, IMapView {
|
||||
@@ -156,7 +160,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
lateinit var mDemaningScope: CoroutineScope
|
||||
|
||||
|
||||
private val mHandler: Handler = object : Handler() {
|
||||
private val mHandler: Handler = object : Handler(Looper.getMainLooper()) {
|
||||
override fun handleMessage(msg: Message) {
|
||||
when (msg.what) {
|
||||
ZOOM_CHANGE -> mMapController?.dispatchZoomChanged()
|
||||
@@ -234,7 +238,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
|
||||
|
||||
override fun destory() {
|
||||
if (CompileConfig.DEBUG) {
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "mapop-destory")
|
||||
}
|
||||
isFirst = true
|
||||
@@ -337,7 +341,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
val animationListener = mMarkerCall?.getAnimationListener(markerId)
|
||||
animationListener?.let {
|
||||
mAnimJob?.cancel()
|
||||
mAnimJob = mScope?.launch(Dispatchers.IO){
|
||||
mAnimJob = mScope.launch(Dispatchers.IO){
|
||||
it.onAnimationFinish(markerId, type)
|
||||
}
|
||||
}
|
||||
@@ -377,7 +381,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
|
||||
isTouchingFlag = true
|
||||
|
||||
if (!(mEventController?.isMapTouchListenerListEmpty()?:true)) {
|
||||
if (mEventController?.isMapTouchListenerListEmpty() == false) {
|
||||
val flag = mEventController?.dispatchMapTouchListener(ev)
|
||||
if (flag != null && flag) {
|
||||
return flag
|
||||
@@ -406,7 +410,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
mILockLocation.setLockCar(false)
|
||||
if(isAutoLockCar) {
|
||||
mLockCarJob?.cancel()
|
||||
mLockCarJob = mDemaningScope?.launch(Dispatchers.IO) {
|
||||
mLockCarJob = mDemaningScope.launch(Dispatchers.IO) {
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "lockop--onTouchEvent:mLockCarJob start: ${mMapStyleParams.getVrAngleMode()}")
|
||||
}
|
||||
@@ -438,7 +442,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
//跳到3d效果
|
||||
val dy0 = m_iLastY0 - ev.getY(0)
|
||||
val dy1 = m_iLastY1 - ev.getY(1)
|
||||
if (Math.abs(dy0) > 1 || Math.abs(dy1) > 1) {
|
||||
if (abs(dy0) > 1 || abs(dy1) > 1) {
|
||||
if (dy1 * dy0 > 1 && dy1 / dy0 < 3 && dy0 / dy1 < 3) {
|
||||
|
||||
if (isFling) {
|
||||
@@ -456,15 +460,15 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
if (!m_bBending) {
|
||||
val dx = ev.getX(1) - ev.getX(0)
|
||||
val dy = ev.getY(1) - ev.getY(0)
|
||||
val dist = Math.sqrt(dx * dx + dy * dy.toDouble()).toFloat()
|
||||
val dist = sqrt(dx * dx + dy * dy.toDouble()).toFloat()
|
||||
//角度
|
||||
angle = (Math.acos(dx / dist.toDouble()) * 180.0 / Math.PI).toInt()
|
||||
angle = (acos(dx / dist.toDouble()) * 180.0 / Math.PI).toInt()
|
||||
if (dy < 0) {
|
||||
angle = 360 - angle
|
||||
}
|
||||
}
|
||||
if (m_bLastMultiple
|
||||
&& (Math.abs(angle - m_iLastAngle) > 10 || m_bRotating)
|
||||
&& (abs(angle - m_iLastAngle) > 10 || m_bRotating)
|
||||
&& !m_bBending
|
||||
) {
|
||||
val dx0 = m_iLastX0 - ev.getX(0)
|
||||
@@ -473,7 +477,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
val dy1 = m_iLastY1 - ev.getY(1)
|
||||
if (dx0 * dx1 < -10 || dy0 * dy1 < -10) {
|
||||
m_bRotating = true
|
||||
//m_MapCtrl.stopAnimation(MapAnimator.ANITYPE_NANGLE, false);
|
||||
//m_MapCtrl.stopAnimation(MapAnimator.ANITYPE_NANGLE, false)
|
||||
if (isRotate && m_bRotating) {
|
||||
if (DEBUG && mShowTouchInfo) {
|
||||
Log.i(TAG, "touchop--rotateBy")
|
||||
@@ -496,7 +500,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
mMapEngine.setScaleMapCenter(it.lon, it.lat)
|
||||
mScaleCenterLonLat = null
|
||||
}
|
||||
val interValue = Math.abs(m_fCurAverageDistanceFromCenter - m_fLastAverageDistanceFromCenter)
|
||||
val interValue = abs(m_fCurAverageDistanceFromCenter - m_fLastAverageDistanceFromCenter)
|
||||
if (m_iMultiTouchCnt > 5 && m_fLastAverageDistanceFromCenter != -1f && interValue > SCALE_SMALL_DISTANCE && ev.action and MotionEvent.ACTION_MASK == MotionEvent.ACTION_MOVE) {
|
||||
val zoomFactor = m_fCurAverageDistanceFromCenter / m_fLastAverageDistanceFromCenter
|
||||
if (isCanZoom) {
|
||||
@@ -511,7 +515,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
// lastScaleByTime = SystemClock.uptimeMillis()
|
||||
if(isVr && (mMapStyleParams.getStyleMode() == MapAutoApi.MAP_STYLE_NIGHT_VR || mMapStyleParams.getStyleMode() == MapAutoApi.MAP_STYLE_DAY_VR)){
|
||||
if(DEBUG) {
|
||||
Log.d(TAG, "getZoomVal(): ${mMapEngine.getZoomValue()}, ${zoomFactor}")
|
||||
Log.d(TAG, "getZoomVal(): ${mMapEngine.getZoomValue()}, $zoomFactor")
|
||||
}
|
||||
//zoomFactor 缩放比例 > 1 放大 < 1 缩小 getZoomVal() / zoomFactor 缩放到的值
|
||||
if(mMapEngine.getZoomValue() / zoomFactor < 3.0) {
|
||||
@@ -542,7 +546,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
m_iLastY1 = ev.getY(1)
|
||||
if (ev.action == MotionEvent.ACTION_UP || ev.action == MotionEvent.ACTION_CANCEL) {
|
||||
m_iLastAngle = NOT_A_ANGLE
|
||||
//m_bLastMultiple = false;
|
||||
//m_bLastMultiple = false
|
||||
m_bBending = false
|
||||
m_bRotating = false
|
||||
}
|
||||
@@ -557,7 +561,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
mGestureDetector.onTouchEvent(ev)
|
||||
}
|
||||
m_iLastAngle = NOT_A_ANGLE
|
||||
//m_bLastMultiple = false;
|
||||
//m_bLastMultiple = false
|
||||
m_bBending = false
|
||||
m_bRotating = false
|
||||
m_iMultiTouchCnt = 0
|
||||
@@ -643,7 +647,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
}
|
||||
if(enableSync){
|
||||
// 2ms是每次耗时补充
|
||||
var sTime = renderTimePer-(System.currentTimeMillis()-time)-2
|
||||
val sTime = renderTimePer-(System.currentTimeMillis()-time)-2
|
||||
if(sTime > 0 && sTime < 100){
|
||||
try {
|
||||
Thread.sleep(sTime)
|
||||
@@ -732,8 +736,8 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
mLockCar?.cancel()
|
||||
mScope.cancel()
|
||||
mDemaningScope.cancel()
|
||||
mHandler?.removeCallbacksAndMessages(null)
|
||||
if (CompileConfig.DEBUG) {
|
||||
mHandler.removeCallbacksAndMessages(null)
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "destroyop--MapEngine.unload-start")
|
||||
}
|
||||
mMapEngine.unload()
|
||||
@@ -748,8 +752,8 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "mapop-surfaceop----onSurfaceCreated:,threadop:${Thread.currentThread().id}")
|
||||
}
|
||||
// setStyleDir("sdcard/shmdata/style");
|
||||
var styleMode = mMapStyleParams.getStyleMode()
|
||||
// setStyleDir("sdcard/shmdata/style")
|
||||
val styleMode = mMapStyleParams.getStyleMode()
|
||||
val dir = Constant.nDSDataPath
|
||||
mMapEngine.setIsEnableShadow(mMapStyleParams.isShadowEnable())
|
||||
if(!loadP(dir)){
|
||||
@@ -854,15 +858,15 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
// return false
|
||||
// }
|
||||
// var y = e.getY()
|
||||
// val sxy = M3DEsngine.glToPixel(0, getHeight() * 2, 0);
|
||||
// val miny = Math.max(0, (short)(sxy & 0xFFFF));
|
||||
// val sxy = M3DEsngine.glToPixel(0, getHeight() * 2, 0)
|
||||
// val miny = Math.max(0, (short)(sxy & 0xFFFF))
|
||||
// if(y < miny){
|
||||
// y = miny;
|
||||
// return true;
|
||||
// y = miny
|
||||
// return true
|
||||
// }
|
||||
// var lonLat = pixelsToLonlat(e.getX().toInt(), y.toInt());
|
||||
// var lonLat = pixelsToLonlat(e.getX().toInt(), y.toInt())
|
||||
// lonLat?.let {
|
||||
// animateTo(lonLat.lon.toFloat(), lonLat.lat.toFloat(),-1f,-1f,-1f);
|
||||
// animateTo(lonLat.lon.toFloat(), lonLat.lat.toFloat(),-1f,-1f,-1f)
|
||||
// }
|
||||
// return true
|
||||
return false
|
||||
@@ -881,15 +885,15 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
val x = e.x.toInt()
|
||||
val y = e.y.toInt()
|
||||
mMarkerJob?.cancel()
|
||||
mMarkerJob = mDemaningScope?.launch(Dispatchers.IO) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
mMarkerJob = mDemaningScope.launch(Dispatchers.IO) {
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "markerop--findAnchorAtScreenPoint:start")
|
||||
}
|
||||
if(!mSurfaceCreated.get()){
|
||||
return@launch
|
||||
}
|
||||
val resultInfo = mMapEngine.findAnchorAtScreen(x, y)
|
||||
if (CompileConfig.DEBUG) {
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "markerop--findAnchorAtScreenPoint:${resultInfo}")
|
||||
}
|
||||
if (TextUtils.isEmpty(resultInfo) || resultInfo == "unableBeTouch") {
|
||||
@@ -897,7 +901,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
val markerInfo = jsonToObj(resultInfo)
|
||||
|
||||
if (markerInfo != null) {
|
||||
var marker: Marker = Marker(MarkerOptions(markerInfo.id,null).setGps(true).position(
|
||||
val marker: Marker = Marker(MarkerOptions(markerInfo.id,null).setGps(true).position(
|
||||
LonLatPoint(markerInfo.lon, markerInfo.lat)
|
||||
).setAssInfo(markerInfo.assInfo),mMapController,mMarkerCall)
|
||||
lastClickMarker?.let {
|
||||
@@ -908,7 +912,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
lastClickMarker = marker
|
||||
|
||||
if (markerInfo.type == "1") {
|
||||
if (!(mEventController?.isMarkClickListenerListEmpty()?:true)) {
|
||||
if (mEventController?.isMarkClickListenerListEmpty() == false) {
|
||||
withContext(Dispatchers.Main) { mEventController?.dispatchMarkClickListener(marker) }
|
||||
}
|
||||
val onMarkClickListener = mMarkerCall?.getMarkClickListener(markerInfo.id)
|
||||
@@ -917,7 +921,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
mILockLocation.setLockCar(false)
|
||||
it.onMarkClick(marker)
|
||||
mLockCarJob?.cancel()
|
||||
mLockCarJob = mDemaningScope?.launch(Dispatchers.IO) {
|
||||
mLockCarJob = mDemaningScope.launch(Dispatchers.IO) {
|
||||
delay(waitTime)
|
||||
mILockLocation.setLockCar(true)
|
||||
}
|
||||
@@ -960,12 +964,12 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
return
|
||||
}
|
||||
mLongPressJob?.cancel()
|
||||
mLongPressJob = mScope?.launch(Dispatchers.IO) {
|
||||
mLongPressJob = mScope.launch(Dispatchers.IO) {
|
||||
if(!mSurfaceCreated.get()){
|
||||
return@launch
|
||||
}
|
||||
val resultInfo = mMapEngine.findAnchorAtScreen(x.toInt(), y.toInt())
|
||||
if (CompileConfig.DEBUG) {
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "markerop--touch--findAnchorAtScreenPoint:${resultInfo}")
|
||||
}
|
||||
if (TextUtils.isEmpty(resultInfo) || resultInfo == "unableBeTouch") {
|
||||
@@ -1013,10 +1017,10 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
//Marker Event
|
||||
markerEvent(e)
|
||||
|
||||
if (!(mEventController?.isMarkClickListenerListEmpty()?:true)) {
|
||||
if (mEventController?.isMarkClickListenerListEmpty() == false) {
|
||||
val x = e.x.toInt()
|
||||
val y = e.y.toInt()
|
||||
var latLonPoint = MapTools.fromScreenLocation(Point(x, y),mMapController)
|
||||
val latLonPoint = MapTools.fromScreenLocation(Point(x, y),mMapController)
|
||||
mEventController?.dispatchMapClickListener(latLonPoint)
|
||||
return true
|
||||
}
|
||||
@@ -1049,14 +1053,14 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
return false
|
||||
}
|
||||
if (velocityX.absoluteValue > 200 || velocityY.absoluteValue > 200) {
|
||||
var x1 = e1.x
|
||||
var y1 = e1.y
|
||||
var x2 = e2.x
|
||||
var y2 = e2.y
|
||||
var distanceX = x2 - x1
|
||||
var distanceY = y2 - y1
|
||||
var inertiaX = 1 + velocityX.absoluteValue / VELOCITY_MEASURE
|
||||
var inertiaY = 1 + velocityY.absoluteValue / VELOCITY_MEASURE
|
||||
val x1 = e1.x
|
||||
val y1 = e1.y
|
||||
val x2 = e2.x
|
||||
val y2 = e2.y
|
||||
val distanceX = x2 - x1
|
||||
val distanceY = y2 - y1
|
||||
val inertiaX = 1 + velocityX.absoluteValue / VELOCITY_MEASURE
|
||||
val inertiaY = 1 + velocityY.absoluteValue / VELOCITY_MEASURE
|
||||
if (DEBUG && mShowTouchInfo) {
|
||||
Log.i(TAG, "touchop--mGestureDetector--onFling--inertia:${inertiaX},${inertiaY},distance:${distanceX},${distanceY},scrollby:${inertiaX * distanceX},${-inertiaY * distanceY}")
|
||||
}
|
||||
@@ -1070,10 +1074,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
mMapEngine.scrollByAnim(scrollX, scrollY)
|
||||
}
|
||||
}
|
||||
|
||||
return if (!isFling) {
|
||||
false
|
||||
} else true
|
||||
return isFling
|
||||
}
|
||||
|
||||
// 参数:
|
||||
@@ -1230,7 +1231,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
Log.i(TAG, "loadop--${mMapParams.getStyleDir()}")
|
||||
}
|
||||
if (!TextUtils.isEmpty(mMapParams.getStyleDir())) {
|
||||
mMapEngine.setStyleDir(mMapParams.getStyleDir()!!)
|
||||
mMapEngine.setStyleDir(mMapParams.getStyleDir())
|
||||
} else if (!TextUtils.isEmpty(mStylePath)) {
|
||||
mMapEngine.setStyleDir(mStylePath!!)
|
||||
}
|
||||
@@ -1312,18 +1313,18 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
}
|
||||
|
||||
private fun renderDataCallback(data: String) {
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.d("renderDataCallback", "renderDataCallback:$data")
|
||||
}
|
||||
renderDataCall?.renderDataResult(data)
|
||||
}
|
||||
|
||||
|
||||
override fun getScope():CoroutineScope?{
|
||||
override fun getScope(): CoroutineScope {
|
||||
return mScope
|
||||
}
|
||||
|
||||
override fun getDemaningScope():CoroutineScope?{
|
||||
override fun getDemaningScope(): CoroutineScope {
|
||||
return mDemaningScope
|
||||
}
|
||||
|
||||
@@ -1345,7 +1346,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
Log.i(TAG, "mapop---renderop-init:${this} ")
|
||||
}
|
||||
isFirst = true
|
||||
getHolder().setType(SurfaceHolder.SURFACE_TYPE_HARDWARE);
|
||||
holder.setType(SurfaceHolder.SURFACE_TYPE_HARDWARE)
|
||||
//setEGLContextClientVersion(3)
|
||||
setEGLConfigChooser { egl, display ->
|
||||
|
||||
@@ -1367,7 +1368,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
|
||||
egl.eglChooseConfig(display, attributes, configs, 1, result)
|
||||
configs[0]
|
||||
}
|
||||
setEGLContextClientVersion(3);
|
||||
setEGLContextClientVersion(3)
|
||||
setRenderer(this)
|
||||
//getHolder().setFormat(PixelFormat.TRANSLUCENT)
|
||||
mGestureDetector = GestureDetector(context, TouchGestureDetecter())
|
||||
|
||||
@@ -10,7 +10,7 @@ import io.netty.buffer.Unpooled;
|
||||
public class PayloadDecoder {
|
||||
|
||||
public static <T extends Codecable> T resolve(byte[] src, Class<T> clazz) {
|
||||
T instance = null;
|
||||
T instance;
|
||||
try {
|
||||
instance = clazz.newInstance();
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -13,8 +13,9 @@ import com.zhidaoauto.map.sdk.open.abs.view.IMapStyleParams
|
||||
import com.zhidaoauto.map.sdk.open.location.MyLocationStyle
|
||||
import io.netty.util.internal.StringUtil
|
||||
|
||||
class LocationHelper(private var mContext: Context?, private var mMarkerController: IMarkerController?,
|
||||
private var mMapController: IMapController?, private var mMapStyleParams: IMapStyleParams?):ILocationView {
|
||||
class LocationHelper(
|
||||
mContext: Context?, mMarkerController: IMarkerController?,
|
||||
mMapController: IMapController?, mMapStyleParams: IMapStyleParams?):ILocationView {
|
||||
private val TAG = "LocationHelper"
|
||||
|
||||
private var myLocationEnabled: Boolean = false
|
||||
|
||||
@@ -104,7 +104,7 @@ class MapAnimate(private val mMapController: IMapController) {
|
||||
var eyeHeight = 0f
|
||||
var angle = 0f
|
||||
var zoomVal = 0f
|
||||
var factor = ((System.currentTimeMillis() - startTime) / duration.toFloat())
|
||||
val factor = ((System.currentTimeMillis() - startTime) / duration.toFloat())
|
||||
|
||||
if( factor >=1){
|
||||
endAnimation()
|
||||
@@ -116,7 +116,7 @@ class MapAnimate(private val mMapController: IMapController) {
|
||||
}
|
||||
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.d(TAG, "angle: ${angle}, height: ${eyeHeight}, zoomVal: ${zoomVal}")
|
||||
Log.d(TAG, "angle: ${angle}, height: ${eyeHeight}, zoomVal: $zoomVal")
|
||||
}
|
||||
return floatArrayOf(zoomVal,angle,eyeHeight)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.zhidaoauto.map.sdk.inner.map
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.Message
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
@@ -12,7 +13,6 @@ import com.autonavi.nge.map.OnMapScreenShotListener
|
||||
import com.autonavi.nge.map.Pixels
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
import com.zhidaoauto.map.data.road.CenterLine
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig.DEBUG
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IEventController
|
||||
import com.zhidaoauto.map.sdk.inner.abs.ILocationView
|
||||
@@ -52,6 +52,7 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import kotlin.math.abs
|
||||
|
||||
class MapController(private var context: Context?, private val mMapView: IMapView
|
||||
,private val mLockLocation:ILockLocation,private val mEventController:IEventController?,private val mMapStyleParams: IMapStyleParams
|
||||
@@ -117,9 +118,9 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
|
||||
override fun getMapScreenShot(var1: OnMapScreenShotListener) {}
|
||||
|
||||
// return mMapView.getVersion();
|
||||
// return mMapView.getVersion()
|
||||
val version: String
|
||||
get() =// return mMapView.getVersion();
|
||||
get() =// return mMapView.getVersion()
|
||||
""
|
||||
|
||||
fun createMapViewInstance() {}
|
||||
@@ -147,7 +148,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCenter(): MapCoordinate? {
|
||||
override fun getCenter(): MapCoordinate {
|
||||
val mCenter = DoubleArray(2)
|
||||
mMapView.getMapEngine().getCenter(mCenter)
|
||||
return MapCoordinate((mCenter[0] * ConstantExt.RULE_INT).toInt(), (mCenter[1] * ConstantExt.RULE_INT).toInt())
|
||||
@@ -167,25 +168,25 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
}
|
||||
|
||||
fun displayRoute(): Boolean {
|
||||
// return mMapView.displayRoute();
|
||||
// return mMapView.displayRoute()
|
||||
return true
|
||||
}
|
||||
|
||||
fun hideRoute(): Boolean {
|
||||
// return mMapView.hideRoute();
|
||||
// return mMapView.hideRoute()
|
||||
return true
|
||||
}
|
||||
|
||||
fun ConvertPixelCoordsToGeoCoords(x: Int, y: Int, lon: Double, lat: Double) {
|
||||
// mMapView.ConvertPixelCoordsToGeoCoords(int x, int y, double lon, double lat);
|
||||
// mMapView.ConvertPixelCoordsToGeoCoords(int x, int y, double lon, double lat)
|
||||
}
|
||||
|
||||
fun ConvertGeoCoordsToPixelCoords(x: Int, y: Int, lon: Double, lat: Double) {
|
||||
// mMapView.ConvertGeoCoordsToPixelCoords(int x, int y, double lon, double lat);
|
||||
// mMapView.ConvertGeoCoordsToPixelCoords(int x, int y, double lon, double lat)
|
||||
}
|
||||
|
||||
fun addOverLay(lon: Double, lat: Double /*, OverLay overLay*/) {
|
||||
// mMapView.addOverLay(double lon, double lat, OverLay overLay);
|
||||
// mMapView.addOverLay(double lon, double lat, OverLay overLay)
|
||||
}
|
||||
|
||||
override fun rotate(rotateAngle: Float) {
|
||||
@@ -254,12 +255,12 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
}
|
||||
|
||||
fun canZoomIn(): Boolean {
|
||||
// return mMapView.canZoomIn();
|
||||
// return mMapView.canZoomIn()
|
||||
return true
|
||||
}
|
||||
|
||||
fun canZoomOut(): Boolean {
|
||||
// return mMapView.canZoomOut();
|
||||
// return mMapView.canZoomOut()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -615,7 +616,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
fun initCar(lon: Long, lat: Long, z: Int, r: Int, carResId: Int) {
|
||||
if (null == mCar) {
|
||||
mCar = M3DCar(context, carResId)
|
||||
mMapView.getMapEngine().drawCar(lon, lat, z.toShort(), r.toShort(), 65536, 1f, mCar!!.totBuffer, mCar!!.totSize);
|
||||
mMapView.getMapEngine().drawCar(lon, lat, z.toShort(), r.toShort(), 65536, 1f, mCar!!.totBuffer, mCar!!.totSize)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -627,7 +628,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
}
|
||||
|
||||
override fun updateCar(lon: Long, lat: Long, z: Int, r: Int, bitmap: Bitmap) {
|
||||
// Marker marker = drawMarker(bitmap);
|
||||
// Marker marker = drawMarker(bitmap)
|
||||
}
|
||||
|
||||
override fun updateCar(lon: Long, lat: Long, z: Short, angle: Short) {
|
||||
@@ -703,9 +704,9 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
private fun setMarkerScale(){
|
||||
zoomJob?.cancel()
|
||||
zoomJob = getDemaningScope()?.launch(Dispatchers.IO) {
|
||||
var currentZoomVal = mMapView.getMapEngine().getZoomValue()
|
||||
val currentZoomVal = mMapView.getMapEngine().getZoomValue()
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "dispatchZoomChanged--currentZoomVal: ${currentZoomVal}")
|
||||
Log.d(TAG, "dispatchZoomChanged--currentZoomVal: $currentZoomVal")
|
||||
}
|
||||
var scale = 0.1f
|
||||
if (currentZoomVal >= 0.125 && currentZoomVal < 0.25) {
|
||||
@@ -723,7 +724,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
}
|
||||
mMapView.getMapEngine().setAnchorRate(scale)
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "dispatchZoomChanged--scale: ${scale}")
|
||||
Log.d(TAG, "dispatchZoomChanged--scale: $scale")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -732,7 +733,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
override fun dispatchDAngleChanged() {
|
||||
val angle = getDAngle().toInt()
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "styleop-DAngle: ${angle}")
|
||||
Log.d(TAG, "styleop-DAngle: $angle")
|
||||
}
|
||||
// val listeners = mMapView.getM_DAngleListenerList()
|
||||
// if (listeners != null && listeners.size > 0) {
|
||||
@@ -746,7 +747,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
|
||||
//来回摆动
|
||||
override fun getDAngle(): Float {
|
||||
//dispatchDAngleChanged();
|
||||
//dispatchDAngleChanged()
|
||||
return mMapView.getMapEngine().getDAngle()
|
||||
}
|
||||
|
||||
@@ -766,10 +767,10 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
override fun setMapViewPerspective(mapPerspective: Int) {
|
||||
mMapPerspective = mapPerspective
|
||||
when (mapPerspective) {
|
||||
MAP_PERSPECTIVE_2D -> //mMapView.setDAngle(90);
|
||||
MAP_PERSPECTIVE_2D -> //mMapView.setDAngle(90)
|
||||
interpolation(ConstantExt.MAP_STYLE_2D_EYE_HEIGHT, ConstantExt.MAP_STYLE_2D_OVER_LOOK_ANGLE, ConstantExt.MAP_STYLE_2D_ZOOM.toFloat(), -1, -1)
|
||||
MAP_PERSPECTIVE_3D -> {
|
||||
//mMapView.setDAngle(45);
|
||||
//mMapView.setDAngle(45)
|
||||
setMapViewVisualAngle(mMapStyleParams.getDefaultPerspective())
|
||||
mMapView.getMapEngine().lookUpDown(-1f)
|
||||
lookUpDown()
|
||||
@@ -811,7 +812,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
*
|
||||
*/
|
||||
private fun setMapStyle(stylemode:Int, isZoom:Boolean){
|
||||
if (CompileConfig.DEBUG) {
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "styleop-setMapStyle-start:${stylemode},${isZoom}")
|
||||
}
|
||||
if(mMapStyleMode == stylemode){
|
||||
@@ -875,7 +876,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
// }
|
||||
|
||||
mILocationView?.switch(stylemode)
|
||||
if (CompileConfig.DEBUG) {
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "styleop-setMapStyle-end:${stylemode}")
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
@@ -942,8 +943,8 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
rotateAngle: Float, //加是逆时针,减是顺时针
|
||||
mDuration: Int
|
||||
) {
|
||||
var arrays = mapAnimate.stepAnimation()
|
||||
if (CompileConfig.DEBUG) {
|
||||
val arrays = mapAnimate.stepAnimation()
|
||||
if (DEBUG) {
|
||||
Log.d(
|
||||
TAG,
|
||||
"animaop--n:${lon},t:${lat},a:${rotateAngle},z: ${arrays[0]}, la: ${arrays[1]}, eh: ${arrays[2]}"
|
||||
@@ -993,7 +994,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
val data = polylineOptions.lonLats
|
||||
var polyline: Polyline? = null
|
||||
try {
|
||||
if (data == null || data.size <= 1) {
|
||||
if (data.size <= 1) {
|
||||
throw RuntimeException("传入的坐标数必须大于1")
|
||||
}
|
||||
val strOptionsJson = JSON.toJSONString(polylineOptions)
|
||||
@@ -1022,7 +1023,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
val colorSize = colorValues?.size ?: 0
|
||||
var polyline: Polyline? = null
|
||||
try {
|
||||
if (data == null || data.size <= 1) {
|
||||
if (data.size <= 1) {
|
||||
throw RuntimeException("传入的坐标数必须大于1")
|
||||
}
|
||||
if (polylineOptions.getIsGradient() && colorSize > data.size) {
|
||||
@@ -1058,12 +1059,12 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
val data = deadZoneOptions.getPosition()
|
||||
var deadZone: DeadZone? = null
|
||||
try {
|
||||
if (data == null || data.size <= 1) {
|
||||
if (data.size <= 1) {
|
||||
throw RuntimeException("传入的坐标数必须大于1")
|
||||
}
|
||||
val strOptionsJson = JSON.toJSONString(deadZoneOptions)
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "deadZoneOptions: ${strOptionsJson}")
|
||||
Log.i(TAG, "deadZoneOptions: $strOptionsJson")
|
||||
}
|
||||
|
||||
drawDeadZone(strOptionsJson)
|
||||
@@ -1131,9 +1132,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
val green = (paintColor shr 8 and 0xff).toChar()
|
||||
val blue = (paintColor and 0xff).toChar()
|
||||
//native实现
|
||||
if (id != null) {
|
||||
mMapView.getMapEngine().drawEllipse(id, doubles, red, green, blue, alpha)
|
||||
}
|
||||
mMapView.getMapEngine().drawEllipse(id, doubles, red, green, blue, alpha)
|
||||
//mMapView.shakeSceneManual()
|
||||
polyline = Polyline(polylineOptions, this)
|
||||
} catch (e: Exception) {
|
||||
@@ -1166,9 +1165,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
val green = (paintColor shr 8 and 0xff).toChar()
|
||||
val blue = (paintColor and 0xff).toChar()
|
||||
//native实现
|
||||
if (id != null) {
|
||||
mMapView.getMapEngine().drawPolygon(id, doubles, red, green, blue, alpha)
|
||||
}
|
||||
mMapView.getMapEngine().drawPolygon(id, doubles, red, green, blue, alpha)
|
||||
//mMapView.shakeSceneManual()
|
||||
polyline = Polyline(polylineOptions, this)
|
||||
} catch (e: Exception) {
|
||||
@@ -1214,17 +1211,14 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
}
|
||||
|
||||
override fun clearPel(): Boolean {
|
||||
val clear = mMapView.getMapEngine().clearAllPrimitives()
|
||||
//mMapView.shakeSceneManual()
|
||||
return clear
|
||||
return mMapView.getMapEngine().clearAllPrimitives()
|
||||
}
|
||||
|
||||
|
||||
override fun setRenderFrequency(enableSync: Boolean, renderTimePer: Int) {
|
||||
mMapView.setSyncRenderFrequency(enableSync, renderTimePer)
|
||||
}
|
||||
|
||||
private val mHandler: Handler = object : Handler() {
|
||||
private val mHandler: Handler = object : Handler(Looper.getMainLooper()) {
|
||||
override fun handleMessage(msg: Message) {
|
||||
when (msg.what) {
|
||||
LOCK_CAR -> {
|
||||
@@ -1244,6 +1238,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var mRoamlist = CopyOnWriteArrayList<LonLatPoint>()
|
||||
var remainList = CopyOnWriteArrayList<LonLatPoint>()
|
||||
var mLastPosition = LonLatPoint()
|
||||
@@ -1269,7 +1264,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
}
|
||||
transJob?.cancel()
|
||||
//还原漫游模式状态结束
|
||||
if (mLockLocation.getLockCar() == false && type != ConstantExt.MAP_STYLE_VR_ROAM) {
|
||||
if (!mLockLocation.getLockCar() && type != ConstantExt.MAP_STYLE_VR_ROAM) {
|
||||
mLockLocation.setLockCar(true)
|
||||
}
|
||||
if (type != ConstantExt.MAP_STYLE_VR_SKY_BOX) {
|
||||
@@ -1295,7 +1290,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
ConstantExt.MAP_STYLE_VR_ZOOM_VAL_MIDDLE_XIAOBA,
|
||||
ConstantExt.MAP_STYLE_VR_ANGLE_MIDDLE_XIAOBA,
|
||||
-1
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
ConstantExt.MAP_STYLE_VR_ERHAI_B2 -> {
|
||||
@@ -1327,7 +1322,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
// instance.mapAutoView?.getMapAutoViewHelper()?.animateTo(ConstantExt.MAP_STYLE_VR_ZOOM_VAL_FAR, ConstantExt.MAP_STYLE_VR_OVER_LOOK_ANGLE_FAR, ConstantExt.MAP_STYLE_VR_EYE_HEIGHT_FAR, 500)
|
||||
mMapStyleParams.setVrAngleMode(ConstantExt.MAP_STYLE_VR_ANGLE_FAR)
|
||||
mHandler.sendEmptyMessageDelayed(NO_LOCK_CAR, 3000)
|
||||
// mMapView.getMapEngine().setDAngle(mMapView.getMapEngine().getDAngle()+0.1f);
|
||||
// mMapView.getMapEngine().setDAngle(mMapView.getMapEngine().getDAngle()+0.1f)
|
||||
// mHandler.sendEmptyMessageDelayed(MAP_STYLE_FAR, 1100)
|
||||
// mMapView.setIsFarViewAngel(true)
|
||||
// mMapView.setUpdateCount(200)
|
||||
@@ -1445,7 +1440,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
roadLineTimeJob?.cancel()
|
||||
roamJob?.cancel()
|
||||
|
||||
var currentLonLat = mLockLocation.getCurrentLonLatPoint()
|
||||
val currentLonLat = mLockLocation.getCurrentLonLatPoint()
|
||||
mLastPosition = currentLonLat
|
||||
if (mTravel.isNotEmpty() && isUseTrace == 1) {
|
||||
mRoamlist = CopyOnWriteArrayList(
|
||||
@@ -1461,8 +1456,8 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
if(mRoamlist.size >=2) {
|
||||
startRoam()
|
||||
}else {
|
||||
var isCancelTimeJob = AtomicBoolean(false)
|
||||
var isCancelRoadLineJob = AtomicBoolean(false)
|
||||
val isCancelTimeJob = AtomicBoolean(false)
|
||||
val isCancelRoadLineJob = AtomicBoolean(false)
|
||||
roadLineJob?.cancel()
|
||||
roadLineJob = getScope()?.launch(Dispatchers.IO) {
|
||||
RoadHelper.getInstance()?.getCenterLineRoadNode(
|
||||
@@ -1471,17 +1466,17 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
currentLonLat.angle.toFloat(),
|
||||
mRoamDis,
|
||||
object : IResult<CenterLine> {
|
||||
override fun result(code: Int, rodeCenterLine: CenterLine?) {
|
||||
override fun result(code: Int, result: CenterLine?) {
|
||||
if(isCancelRoadLineJob.get()) {
|
||||
return
|
||||
}
|
||||
roadLineTimeJob?.cancel()
|
||||
isCancelTimeJob.set(true)
|
||||
if (rodeCenterLine != null && rodeCenterLine!!.points != null && rodeCenterLine.points!!.size >= 2) {
|
||||
if (result != null && result.points.size >= 2) {
|
||||
mRoamlist = CopyOnWriteArrayList(
|
||||
MathUtils.getSmoothPoints(
|
||||
MathUtils.getPoints(
|
||||
ArrayList(rodeCenterLine.points),
|
||||
ArrayList(result.points),
|
||||
mSpeed * 0.1f
|
||||
)
|
||||
)
|
||||
@@ -1535,7 +1530,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
roamJob?.cancel()
|
||||
roamJob = getDemaningScope()?.launch(Dispatchers.IO) {
|
||||
try {
|
||||
var disRoam = MathUtils.distance(mRoamlist.first(), mRoamlist.last())
|
||||
val disRoam = MathUtils.distance(mRoamlist.first(), mRoamlist.last())
|
||||
if (disRoam < 100) {
|
||||
Log.e(TAG, "Roam--op--status: 进入漫游模式失败:获取数据距离太短: ${String.format("%.1f", disRoam)}米")
|
||||
withContext(Dispatchers.Main) {
|
||||
@@ -1597,7 +1592,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
|
||||
suspend fun dealRoamMode(){
|
||||
if (mRoamPostion < mRoamlist.size) {
|
||||
var location = mRoamlist[mRoamPostion]
|
||||
val location = mRoamlist[mRoamPostion]
|
||||
var angle = GisGeomTool.GetLineAngle(
|
||||
mLastPosition.longitude,
|
||||
mLastPosition.latitude,
|
||||
@@ -1608,7 +1603,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
if(mRoamPostion == 0){
|
||||
angle = mLastPosition.angle
|
||||
}
|
||||
if (Math.abs(mLastPosition.angle - angle) < 3.5) {
|
||||
if (abs(mLastPosition.angle - angle) < 3.5) {
|
||||
angle = mLastPosition.angle
|
||||
}
|
||||
|
||||
@@ -1735,9 +1730,9 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
if(System.currentTimeMillis() - mLockLocation.getLastUpdateTime() > 500
|
||||
|| mLockLocation.getLastUpdateTime() - mLockLocation.getAgainLastUpdateTime() >= 900){
|
||||
mapAnimate.setStartFrame(zoomVal, angle, eyeHeight)
|
||||
var center = mLockLocation.getCurrentLonLatPoint()
|
||||
var lon: Double = center.longitude
|
||||
var lat: Double = center.latitude
|
||||
val center = mLockLocation.getCurrentLonLatPoint()
|
||||
val lon: Double = center.longitude
|
||||
val lat: Double = center.latitude
|
||||
animateTo(lon, lat, 0f,-1f, 1000)
|
||||
}else {
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ object MapDataHelper {
|
||||
val oldVersion = SharedPrefsMgr.getInstance(context).getInt(ConstantExt.SHARED_KEY_DATA_VERSION, 0)
|
||||
if (oldVersion < currentDataVersion) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"dataop--delete old verion ${oldVersion} for update version ${currentDataVersion}")
|
||||
Log.i(TAG,"dataop--delete old verion $oldVersion for update version $currentDataVersion")
|
||||
}
|
||||
SharedPrefsMgr.getInstance(context).putInt(ConstantExt.SHARED_KEY_DATA_VERSION, currentDataVersion)
|
||||
deleteDataDir(dir)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zhidaoauto.map.sdk.inner.map
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.res.AssetManager
|
||||
import android.util.Log
|
||||
@@ -15,6 +16,7 @@ import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object MapHdDataHelper {
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
@@ -32,7 +34,7 @@ object MapHdDataHelper {
|
||||
val oldVersion = SharedPrefsMgr.getInstance(context).getInt(ConstantExt.SHARED_KEY_HDDATA_VERSION, 0)
|
||||
if (oldVersion < currentDataVersion) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"hdmapop--delete old verion ${oldVersion} for update version ${currentDataVersion}")
|
||||
Log.i(TAG,"hdmapop--delete old verion $oldVersion for update version $currentDataVersion")
|
||||
}
|
||||
FileUtils.deleteDirectory(dir)
|
||||
}
|
||||
@@ -62,7 +64,7 @@ object MapHdDataHelper {
|
||||
val start = System.currentTimeMillis()
|
||||
var result = FileUtils.copyDirect(assetManager, assetDir, dir)
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"hdmapop-assetop-copy to ${dir} cost:${System.currentTimeMillis()-start}ms")
|
||||
Log.i(TAG,"hdmapop-assetop-copy to $dir cost:${System.currentTimeMillis()-start}ms")
|
||||
}
|
||||
if(!result){
|
||||
if(CompileConfig.DEBUG){
|
||||
|
||||
@@ -29,7 +29,7 @@ object MapStyleHelper {
|
||||
val oldVersion = SharedPrefsMgr.getInstance(context).getInt(ConstantExt.SHARED_KEY_STYLE_VERSION, 0)
|
||||
if (oldVersion < currentStyleVersion) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"styleop--delete old verion ${oldVersion} for update version ${currentStyleVersion}")
|
||||
Log.i(TAG,"styleop--delete old verion $oldVersion for update version $currentStyleVersion")
|
||||
}
|
||||
FileUtils.deleteDirectory(dir)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ object MapStyleHelper {
|
||||
val start = System.currentTimeMillis()
|
||||
var result = FileUtils.copyDirect(assetManager, assetDir, dir)
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"styleop-assetop-copy to ${dir} cost:${System.currentTimeMillis()-start}ms")
|
||||
Log.i(TAG,"styleop-assetop-copy to $dir cost:${System.currentTimeMillis()-start}ms")
|
||||
}
|
||||
if(!result){
|
||||
if(CompileConfig.DEBUG){
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.zhidaoauto.map.sdk.inner.map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController;
|
||||
@@ -49,7 +50,7 @@ public class MapZoomAdjuster implements MapStatusListener {
|
||||
}
|
||||
|
||||
void adjustZoomChange(int value, int delaysecond) {
|
||||
if (mMapMode >= NAVMODE && true == mFollowCarMode && value != NAVZOOMLEVEL) {
|
||||
if (mMapMode >= NAVMODE && mFollowCarMode && value != NAVZOOMLEVEL) {
|
||||
cancelAdjustZoomChange();
|
||||
mNaviControllerHandler.sendEmptyMessageDelayed(MSG_ZOOM_CHANGED, 1000*delaysecond); /* delay 10s */
|
||||
}
|
||||
@@ -60,11 +61,10 @@ public class MapZoomAdjuster implements MapStatusListener {
|
||||
}
|
||||
|
||||
|
||||
private Handler mNaviControllerHandler = new Handler() {
|
||||
private final Handler mNaviControllerHandler = new Handler(Looper.getMainLooper()) {
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
|
||||
switch(msg.what) {
|
||||
case MSG_ZOOM_CHANGED:
|
||||
if (null != mMapCtrl) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import android.util.Log
|
||||
import com.alibaba.fastjson.JSON
|
||||
import com.autonavi.nge.map.LonLat
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig.DEBUG
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMarkerCall
|
||||
@@ -23,7 +22,6 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
|
||||
private val TAG = "MarkerNativeInterface"
|
||||
|
||||
|
||||
private val markerIconList = ArrayList<String>()
|
||||
private val markClickListenerMap: MutableMap<String, OnMarkClickListener> = HashMap()
|
||||
private val infoWindowClickListenerMap: MutableMap<String, OnInfoWindowClickListener> = HashMap<String, OnInfoWindowClickListener>()
|
||||
@@ -36,7 +34,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
private val infoViewClickMap = HashMap<String, HashMap<Rect, IInfoViewClick>>()
|
||||
|
||||
override fun exit(){
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--MarkerNativeInterface:exit")
|
||||
}
|
||||
markerIconList.clear()
|
||||
@@ -50,20 +48,19 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
override fun addInfoViewClick(markerId: String, rect: Rect, iInfoViewClick: IInfoViewClick) {
|
||||
var map: HashMap<Rect, IInfoViewClick>?
|
||||
if (infoViewClickMap.containsKey(markerId)) {
|
||||
map = infoViewClickMap.get(markerId)
|
||||
val map: HashMap<Rect, IInfoViewClick>? = if (infoViewClickMap.containsKey(markerId)) {
|
||||
infoViewClickMap[markerId]
|
||||
} else {
|
||||
map = HashMap<Rect, IInfoViewClick>()
|
||||
HashMap<Rect, IInfoViewClick>()
|
||||
}
|
||||
map?.let {
|
||||
it.put(rect, iInfoViewClick)
|
||||
it[rect] = iInfoViewClick
|
||||
infoViewClickMap.put(markerId, it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getInfoViewClick(markerId: String): HashMap<Rect, IInfoViewClick>? {
|
||||
return infoViewClickMap.get(markerId)
|
||||
return infoViewClickMap[markerId]
|
||||
}
|
||||
|
||||
override fun removeInfoViewClick(markerId: String) {
|
||||
@@ -84,11 +81,11 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
override fun addMarkerIconCache(id: Int, icon: String) {
|
||||
markerIconCacheMap.put(id,icon)
|
||||
markerIconCacheMap[id] = icon
|
||||
}
|
||||
|
||||
override fun getMarkerIconCache(id:Int):String?{
|
||||
return markerIconCacheMap.get(id)
|
||||
return markerIconCacheMap[id]
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
@@ -106,7 +103,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
* @return
|
||||
*/
|
||||
fun clearAllMarkers(): Boolean? {
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--clearAllMarkers:")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
@@ -170,7 +167,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
*/
|
||||
fun setIcon(id: String?, bitmapDescriptor: BitmapDescriptor) {
|
||||
val markerBytes = bitmapDescriptor.getBytes()
|
||||
if(markerBytes.size == 0){
|
||||
if(markerBytes.isEmpty()){
|
||||
return
|
||||
}
|
||||
MD5Utils.getInstanse()
|
||||
@@ -249,13 +246,12 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
fun getPosition(id: String?): LonLat? {
|
||||
fun getPosition(id: String?): LonLat {
|
||||
val lonlstStr = getMarkerProperty(id!!, "lonLatPoint")
|
||||
val lonlat = lonlstStr?.split(",")?.toTypedArray()
|
||||
lonlat?.let{
|
||||
val lonlat = lonlstStr.split(",").toTypedArray()
|
||||
lonlat.let{
|
||||
return LonLat(lonlat[0].toDouble(), lonlat[1].toDouble())
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,7 +261,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
* @return
|
||||
*/
|
||||
fun removeMarker(id: String?): Boolean {
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--removeMarker:${id}")
|
||||
}
|
||||
mMapController.removeAnchor(id!!)
|
||||
@@ -281,22 +277,22 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
*/
|
||||
fun isInfoWindowShown(id: String?): Boolean {
|
||||
val isInfoWindowShown = getMarkerProperty(id!!, "isInfoWindowShown")
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--isInfoWindowShown:${isInfoWindowShown}")
|
||||
}
|
||||
return isInfoWindowShown?.toBoolean()?:false
|
||||
return isInfoWindowShown.toBoolean()
|
||||
}
|
||||
|
||||
fun setInfoWindowShown(id: String?,flag:Boolean):Boolean{
|
||||
val isSuccess = updateMarkerProperty(id!!, "isInfoWindowShown", "$flag")
|
||||
refreshMap()
|
||||
return isSuccess?:false
|
||||
return isSuccess
|
||||
}
|
||||
|
||||
fun setInfoWindowEnabled(id: String?,flag:Boolean):Boolean{
|
||||
val isSuccess = updateMarkerProperty(id!!, "infoWindowEnabled", "$flag")
|
||||
refreshMap()
|
||||
return isSuccess?:false
|
||||
return isSuccess
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,10 +303,10 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
*/
|
||||
fun isInfoWindowEnabled(id: String?): Boolean {
|
||||
val infoWindowEnabled = getMarkerProperty(id!!, "infoWindowEnabled")
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--infoWindowEnabled:${infoWindowEnabled}")
|
||||
}
|
||||
return infoWindowEnabled?.toBoolean()?:false
|
||||
return infoWindowEnabled.toBoolean()
|
||||
}
|
||||
|
||||
fun setVisible(id: String?, visible: Boolean) {
|
||||
@@ -319,7 +315,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
fun isVisible(id: String?): Boolean {
|
||||
return getMarkerProperty(id!!, "visible")?.toBoolean()?:false
|
||||
return getMarkerProperty(id!!, "visible").toBoolean()
|
||||
}
|
||||
|
||||
fun setRotateAngle(id: String?, rotateAngle: Float) {
|
||||
@@ -359,7 +355,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
fun showInfoWindow(id: String?) {
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--showInfoWindow:${id}")
|
||||
}
|
||||
mMapController.showInfoWindow(id!!)
|
||||
@@ -367,7 +363,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
fun hideInfoWindow(id: String?) {
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--hideInfoWindow:${id}")
|
||||
}
|
||||
mMapController.hideInfoWindow(id!!)
|
||||
@@ -375,7 +371,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
fun setInfoWindowIcon(id: String?, markerInfoName: String) {
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--setInfoWindowIcon:${id}")
|
||||
}
|
||||
updateMarkerProperty(id!!, "markerInfoName", markerInfoName)
|
||||
@@ -385,19 +381,19 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
private fun getMarkerProperty(id:String,propertyName:String):String{
|
||||
return mMapController.getAnchorProperty(id,propertyName)?:""
|
||||
return mMapController.getAnchorProperty(id,propertyName)
|
||||
}
|
||||
|
||||
private fun updateMarkerProperty(id:String,propertyName:String,value:String):Boolean{
|
||||
val flag = mMapController.updateAnchorProperty(id,propertyName,value)
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--updateMarkerProperty:${id},${propertyName},${value},result:${flag}")
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun clear(): Boolean {
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--clear clearAllAluster --clearAllMarkers:")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
@@ -412,7 +408,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
|
||||
|
||||
override fun getAnimationListener(markerID: String): OnAnimationListener? {
|
||||
if (animationListenerMap == null || animationListenerMap.size == 0) {
|
||||
if (animationListenerMap.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
for (id in animationListenerMap.keys) {
|
||||
@@ -432,7 +428,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
override fun getInfoWindowClickListener(markerID: String): OnInfoWindowClickListener? {
|
||||
if (infoWindowClickListenerMap == null || infoWindowClickListenerMap.size == 0) {
|
||||
if (infoWindowClickListenerMap.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
for (id in infoWindowClickListenerMap.keys) {
|
||||
@@ -468,7 +464,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
override fun getMarkDragListener(markerID: String): OnMarkerDragListener?{
|
||||
if (markDragListenerMap == null || markDragListenerMap.size == 0) {
|
||||
if (markDragListenerMap.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
for (id in markDragListenerMap.keys) {
|
||||
@@ -479,7 +475,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
return null
|
||||
}
|
||||
override fun getMarkClickListener(markerID: String): OnMarkClickListener? {
|
||||
if (markClickListenerMap == null || markClickListenerMap.size == 0) {
|
||||
if (markClickListenerMap.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
for (id in markClickListenerMap.keys) {
|
||||
@@ -500,7 +496,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
fun setClickable(id: String?, clickable: Boolean) {
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--setClickable:${id}")
|
||||
}
|
||||
mMapController.setSomeAnchorCanClickable(id!!, clickable)
|
||||
@@ -509,14 +505,14 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
|
||||
fun addDynamicAnchorPostion(id: String, points: List<LonLatPoint>,angle:Float, isGps:Boolean,current:Long,duration: Int) {
|
||||
val data = MapTools.listToArray(points,!isGps)
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--addDynamicAnchorPostion:${id},${points},isGps:${isGps},duration:${duration}")
|
||||
}
|
||||
mMapController.addDynamicAnchorPostion(id, data,angle,current, duration)
|
||||
}
|
||||
|
||||
fun addTranslateAnimationToAnchor(id: String, points: DoubleArray, duration: Int) {
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--addTranslateAnimationToAnchor:${id}")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
@@ -525,7 +521,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
fun addScaleAnimationToAnchor(id: String, startScale: Float, endScale: Float, duration: Int) {
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--addScaleAnimationToAnchor:${id}")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
@@ -534,7 +530,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
fun addFlashAnimationToAnchorPoint(id: String, images: String, duration: Int){
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--addFlashAnimationToAnchorPoint:${id}")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
@@ -543,7 +539,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
fun addRotateAnimationToAnchorPoint(id: String, startAng: Float, endAng: Float, duration: Int){
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--addRotateAnimationToAnchorPoint:${id}")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
@@ -551,7 +547,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
// }
|
||||
}
|
||||
fun startAnimation(id: String) {
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--startAnimation:${id}")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
@@ -566,7 +562,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
fun setToTop(id: String) {
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--SetSomeAnchorTop:${id}")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
@@ -576,7 +572,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
fun setZIndex(id: String, zIndex: Int) {
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--setZIndex:${id},${zIndex}")
|
||||
}
|
||||
// CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
@@ -598,7 +594,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
|
||||
//设置marker 模型顔色
|
||||
fun set3DAnchorColor(id: String, color: String) {
|
||||
updateMarkerProperty(id!!, "anchorColor", color)
|
||||
updateMarkerProperty(id, "anchorColor", color)
|
||||
}
|
||||
|
||||
fun vrIcon(id: String, flag: Boolean) {
|
||||
@@ -608,8 +604,8 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
|
||||
//设置marker是否可以平贴
|
||||
fun setFlat(id: String, flat: Boolean) {
|
||||
updateMarkerProperty(id!!, "flat", flat.toString())
|
||||
if(CompileConfig.DEBUG){
|
||||
updateMarkerProperty(id, "flat", flat.toString())
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--setFlat:${id},${flat}")
|
||||
}
|
||||
mMapController.setSomeAnchorFlat(id, flat)
|
||||
@@ -618,7 +614,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
|
||||
//设置infowindow的偏移量
|
||||
fun setInfoWindowOffset(id: String, offsetX: Int, offsetY: Int) {
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--setInfoWindowOffset:${id},${offsetX},${offsetY}")
|
||||
}
|
||||
mMapController.setSomeAnchorInfowindowOffset(id, offsetX, offsetY)
|
||||
@@ -626,7 +622,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
fun setMarkerOptions(id: String?, markerPtions: MarkerOptions) {
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--setMarkerOptions:${id},${markerPtions}")
|
||||
}
|
||||
mMapController.updateAnchorByJson(id!!, JSON.toJSONString(markerPtions), ByteArray(0), 0, 0)
|
||||
@@ -646,9 +642,9 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
}
|
||||
|
||||
|
||||
fun addImagetoImageManager(markerIconName: String, markerBytes: ByteArray, width: Int, height: Int ){
|
||||
fun addImageToImageManager(markerIconName: String, markerBytes: ByteArray, width: Int, height: Int ){
|
||||
if (!containMarkerIcon(markerIconName)) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "markerop--setIcon--addImagetoImageManager:${markerIconName}")
|
||||
}
|
||||
val result = mMapController.addImage(
|
||||
@@ -656,8 +652,8 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
markerBytes,
|
||||
width,
|
||||
height
|
||||
)?:-1
|
||||
if (CompileConfig.DEBUG) {
|
||||
)
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "markerop--setIcon--addImagetoImageManager:${markerIconName},result:${result},threadop:${Thread.currentThread().id}")
|
||||
}
|
||||
if (result == 0) {
|
||||
@@ -702,41 +698,41 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
|
||||
* 设置锚点的动画开关
|
||||
*/
|
||||
fun setMarkerDisplayAnimEnable(id: String?, isDisplayAnim: Boolean) {
|
||||
mMapController.updateAnchorProperty(id!!, "isDisplayAnim", "${isDisplayAnim}")
|
||||
mMapController.updateAnchorProperty(id!!, "isDisplayAnim", "$isDisplayAnim")
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置锚点的动画停顿帧数
|
||||
*/
|
||||
fun setMarkerAnimWaitFrame(id: String?, animWaitFrame: Int) {
|
||||
mMapController.updateAnchorProperty(id!!, "animWaitFrame", "${animWaitFrame}")
|
||||
mMapController.updateAnchorProperty(id!!, "animWaitFrame", "$animWaitFrame")
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置锚点的动画类型
|
||||
*/
|
||||
fun setMarkerAnimType(id: String?, animType: Int) {
|
||||
mMapController.updateAnchorProperty(id!!, "animType", "${animType}")
|
||||
mMapController.updateAnchorProperty(id!!, "animType", "$animType")
|
||||
}
|
||||
|
||||
fun setMarkerAnchorType(id: String?, anchorType: Int) {
|
||||
mMapController.updateAnchorProperty(id!!, "anchorType", "${anchorType}")
|
||||
mMapController.updateAnchorProperty(id!!, "anchorType", "$anchorType")
|
||||
}
|
||||
|
||||
fun setMarkerAnchorShadow(id: String?, anchorShadow: Int) {
|
||||
mMapController.updateAnchorProperty(id!!, "anchorShadow", "${anchorShadow}")
|
||||
mMapController.updateAnchorProperty(id!!, "anchorShadow", "$anchorShadow")
|
||||
}
|
||||
|
||||
fun setMarkerColorType(id: String?, colorType: Int) {
|
||||
mMapController.updateAnchorProperty(id!!, "colorType", "${colorType}")
|
||||
mMapController.updateAnchorProperty(id!!, "colorType", "$colorType")
|
||||
}
|
||||
|
||||
fun setMarkerChangerColorTime(id: String?, changerColorTime: Float) {
|
||||
mMapController.updateAnchorProperty(id!!, "changeColorTime", "${changerColorTime}")
|
||||
mMapController.updateAnchorProperty(id!!, "changeColorTime", "$changerColorTime")
|
||||
}
|
||||
|
||||
fun setMarkerChangeColorAngle(id: String?, changeColorAngle: Float) {
|
||||
mMapController.updateAnchorProperty(id!!, "changeColorAngle", "${changeColorAngle}")
|
||||
mMapController.updateAnchorProperty(id!!, "changeColorAngle", "$changeColorAngle")
|
||||
}
|
||||
|
||||
fun setMarkerFlash(id: String, colorType: Int, color: String, time: Float, angle: Float){
|
||||
|
||||
@@ -6,15 +6,9 @@ import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
|
||||
class RecycleController {
|
||||
class RecycleController public constructor() {
|
||||
private val TAG = javaClass.simpleName
|
||||
|
||||
public constructor() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private val renderList: HashSet<String> = HashSet<String>()
|
||||
private val recycleList: CopyOnWriteArrayList<String> = CopyOnWriteArrayList<String>()
|
||||
|
||||
@@ -30,7 +24,7 @@ class RecycleController {
|
||||
}
|
||||
|
||||
fun getRecycle(): String {
|
||||
var id =""
|
||||
var id: String
|
||||
if(recycleList.isEmpty()){
|
||||
// id = UUID.randomUUID().toString().replace("-","")
|
||||
id = idStart.addAndGet(1).toString()
|
||||
|
||||
@@ -6,27 +6,24 @@ import com.zhidaoauto.map.sdk.inner.obj.ResultData
|
||||
|
||||
|
||||
class MapDataHelper private constructor() {
|
||||
val TAG = javaClass.simpleName
|
||||
|
||||
companion object {
|
||||
val instance: MapDataHelper by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
MapDataHelper() }
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun dealValue(key: String,value:String): String {
|
||||
val result = ResultData()
|
||||
result.setKey(key)
|
||||
result.setValue(value)
|
||||
result.key = key
|
||||
result.value = value
|
||||
return JSON.toJSONString(result)
|
||||
}
|
||||
|
||||
|
||||
fun dealValue(key: String, value:ArrayList<SPRouteLine>): String {
|
||||
val result = ResultData()
|
||||
result.setKey(key)
|
||||
result.setValue(JSON.toJSONString(value))
|
||||
result.key = key
|
||||
result.value = JSON.toJSONString(value)
|
||||
return JSON.toJSONString(result)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,11 @@ import org.jetbrains.annotations.Nullable
|
||||
|
||||
class MapDataProvider : ContentProvider() {
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
companion object {
|
||||
private const val TAG = "MapDataProvider"
|
||||
private val mMatcher: UriMatcher = UriMatcher(UriMatcher.NO_MATCH)
|
||||
}
|
||||
|
||||
private var mContext: Context? = null
|
||||
|
||||
override fun onCreate(): Boolean {
|
||||
@@ -44,29 +48,27 @@ class MapDataProvider : ContentProvider() {
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun insert(uri: Uri, values: ContentValues?): Uri? {
|
||||
override fun insert(uri: Uri, values: ContentValues?): Uri {
|
||||
return uri
|
||||
}
|
||||
|
||||
override fun query(
|
||||
@NonNull uri: Uri, projection: Array<String>?, @Nullable key: String?,
|
||||
@Nullable selectionArgs: Array<String>?, @Nullable sortOrder: String?
|
||||
): Cursor? {
|
||||
uri: Uri, projection: Array<String>?, key: String?,
|
||||
selectionArgs: Array<String>?, sortOrder: String?
|
||||
): Cursor {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "queryop = key:${key}")
|
||||
}
|
||||
var cursor: MatrixCursor = MatrixCursor(arrayOf("value"))
|
||||
val cursor = MatrixCursor(arrayOf("value"))
|
||||
if (TextUtils.isEmpty(key)) {
|
||||
return cursor
|
||||
}
|
||||
var result: String? = null
|
||||
|
||||
when (mMatcher.match(uri)) {
|
||||
ConstantExt.CODE_QUERY -> {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "queryop key= ${key}")
|
||||
}
|
||||
var array = key!!.split(",")
|
||||
val array = key!!.split(",")
|
||||
if (array.size < 2) {
|
||||
return cursor
|
||||
}
|
||||
@@ -81,7 +83,7 @@ class MapDataProvider : ContentProvider() {
|
||||
MapDataApi.startZeus(context)
|
||||
Log.i(TAG,"roadop-queryop-start:query:getRouteInfo")
|
||||
val start = System.currentTimeMillis()
|
||||
var value = RoadHelper.getInstance()?.getRoadInfo(array[0].toFloat(),array[1].toFloat(),coor,roadType)
|
||||
val value = RoadHelper.getInstance()?.getRoadInfo(array[0].toFloat(),array[1].toFloat(),coor,roadType)
|
||||
Log.i(TAG,"roadop-queryop-coor:${coor}-end:${(System.currentTimeMillis()-start)}ms")
|
||||
if(value == null || value.isEmpty()){
|
||||
if (CompileConfig.DEBUG) {
|
||||
@@ -89,10 +91,9 @@ class MapDataProvider : ContentProvider() {
|
||||
}
|
||||
return cursor
|
||||
}
|
||||
result = MapDataHelper.instance.dealValue(key!!, value!!)
|
||||
|
||||
val result = MapDataHelper.instance.dealValue(key, value)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "queryop result= ${result}")
|
||||
Log.i(TAG, "queryop result= $result")
|
||||
}
|
||||
cursor.addRow(arrayOf<Any>(result))
|
||||
}
|
||||
@@ -100,17 +101,8 @@ class MapDataProvider : ContentProvider() {
|
||||
return cursor
|
||||
}
|
||||
|
||||
override fun getType(@NonNull uri: Uri): String? {
|
||||
override fun getType(uri: Uri): String? {
|
||||
return null
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private val mMatcher: UriMatcher
|
||||
|
||||
init {
|
||||
mMatcher = UriMatcher(UriMatcher.NO_MATCH)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class CommonProxy {
|
||||
var mInstance: CommonProxy? = null
|
||||
fun getInstance(): CommonProxy {
|
||||
if (mInstance == null) {
|
||||
synchronized(CommonProxy.javaClass) {
|
||||
synchronized(Companion::class.java) {
|
||||
if (mInstance == null) {
|
||||
mInstance = CommonProxy()
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class LonLatProxy : ILonLatProxy {
|
||||
* 转换为外部使用坐标
|
||||
*/
|
||||
override fun switchLonLat(lonLat: LonLat): LonLatPoint {
|
||||
var array: DoubleArray? = null;
|
||||
var array: DoubleArray?
|
||||
when (MapHelper.mMapParams.getCoordinateType()) {
|
||||
MapParams.COORDINATETYPE_GCJ02 -> {
|
||||
array = TransformUtils.transformWgsToGcj(lonLat.lat, lonLat.lon)
|
||||
@@ -45,7 +45,7 @@ class LonLatProxy : ILonLatProxy {
|
||||
* 转换为内部使用坐标
|
||||
*/
|
||||
override fun switchLonLat(lonLatPoint: LonLatPoint): LonLat {
|
||||
var array: DoubleArray? = null
|
||||
var array: DoubleArray?
|
||||
|
||||
when (MapHelper.mMapParams.getCoordinateType()) {
|
||||
MapParams.COORDINATETYPE_GCJ02 -> {
|
||||
|
||||
@@ -15,8 +15,6 @@ class RoadResultController {
|
||||
|
||||
private var mRoadResultCallHashMap: ConcurrentHashMap<String,CopyOnWriteArrayList<IRoadData>> = ConcurrentHashMap()
|
||||
|
||||
|
||||
|
||||
fun addRoadResultListener(key:String,listener:IRoadData){
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "roadop--addRoadResultListener:$key ")
|
||||
@@ -26,7 +24,7 @@ class RoadResultController {
|
||||
list = CopyOnWriteArrayList<IRoadData>()
|
||||
}
|
||||
list.add(listener)
|
||||
mRoadResultCallHashMap.put(key,list)
|
||||
mRoadResultCallHashMap[key] = list
|
||||
}
|
||||
|
||||
fun removeRoadResultListenerByTag(tag:String){
|
||||
@@ -34,7 +32,7 @@ class RoadResultController {
|
||||
Log.i(TAG, "roadop--removeRoadResultListenerByTag:$tag ")
|
||||
}
|
||||
val keysToRemove = mutableListOf<String>()
|
||||
mRoadResultCallHashMap.forEach { (key, value) ->
|
||||
mRoadResultCallHashMap.forEach { (key, _) ->
|
||||
if (key.contains(tag)) {
|
||||
keysToRemove.add(key)
|
||||
}
|
||||
@@ -52,7 +50,7 @@ class RoadResultController {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "roadop--dispatchRoadResultDouble:$key,strResult:$result")
|
||||
}
|
||||
val list = mRoadResultCallHashMap.get(key)
|
||||
val list = mRoadResultCallHashMap[key]
|
||||
if(list != null && list.isNotEmpty()){
|
||||
CommonController.instance.scope?.launch(Dispatchers.Main) {
|
||||
list.forEach { call ->
|
||||
|
||||
@@ -25,7 +25,7 @@ object ZeusManager {
|
||||
// if (CompileConfig.DEBUG) {
|
||||
// Log.i(TAG, "zeusop-start--service:${info.service.className}")
|
||||
// }
|
||||
if (info.service.className.equals(ServiceName)) {
|
||||
if (info.service.className == ServiceName) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,6 @@ class TrafficHelper {
|
||||
|
||||
val TAG = javaClass.simpleName
|
||||
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载TMC数据入口
|
||||
*/
|
||||
|
||||
@@ -84,11 +84,11 @@ class Clerk(private val mMapController: IMapController?) {
|
||||
stringBuffer = StringBuffer()
|
||||
}
|
||||
val content = "${System.currentTimeMillis()},$className,$methodName,$param"
|
||||
if(stringBuffer.length > 0){
|
||||
stringBuffer?.append("\n")
|
||||
if(stringBuffer.isNotEmpty()){
|
||||
stringBuffer.append("\n")
|
||||
}
|
||||
stringBuffer?.append(content)
|
||||
cacheMap.put(key,stringBuffer)
|
||||
stringBuffer.append(content)
|
||||
cacheMap[key] = stringBuffer
|
||||
if(cacheMap.size > 2){
|
||||
save()
|
||||
}
|
||||
@@ -129,7 +129,7 @@ class Clerk(private val mMapController: IMapController?) {
|
||||
val path = Recorder.write(TAG, "${mMapController.hashCode()}",buffer.toString())
|
||||
//处理回调逻辑
|
||||
mLastPath?.let{
|
||||
if(!it.equals(path)){
|
||||
if(it != path){
|
||||
//TODO MATT
|
||||
// CommonEventController.instance.dispatchLog(it)
|
||||
Recorder.checkLog(TAG)
|
||||
|
||||
@@ -78,11 +78,7 @@ public class AMapUtils {
|
||||
public static Boolean notHasLightSensorManager(Context context) {
|
||||
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||
Sensor sensor8 = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); //光
|
||||
if (null == sensor8) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return null == sensor8;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ object BitmapUtils {
|
||||
return null;
|
||||
}
|
||||
try{
|
||||
val result = bitmap.copy(bitmap.getConfig(), true);
|
||||
val result = bitmap.copy(bitmap.config, true);
|
||||
// val canvasBmp2 = Canvas( result );
|
||||
// canvasBmp2.drawBitmap(bitmap,null, Paint())
|
||||
return result
|
||||
|
||||
@@ -10,7 +10,7 @@ class ConcurrentLRUCache<K, V>(private val capacity: Int) {
|
||||
fun put(key: K, value: V) {
|
||||
lock.writeLock().lock()
|
||||
try {
|
||||
map.put(key, value)
|
||||
map[key] = value
|
||||
if (map.size > capacity) {
|
||||
val eldest = map.entries.iterator().next()
|
||||
map.remove(eldest.key)
|
||||
@@ -23,7 +23,7 @@ class ConcurrentLRUCache<K, V>(private val capacity: Int) {
|
||||
fun get(key: K): V? {
|
||||
lock.readLock().lock()
|
||||
try {
|
||||
return map.get(key)
|
||||
return map[key]
|
||||
} finally {
|
||||
lock.readLock().unlock()
|
||||
}
|
||||
|
||||
@@ -41,32 +41,32 @@ object Constant {
|
||||
const val URL_MEDIA = "http://ant.maplay.cn" //媒体
|
||||
|
||||
//测试地址
|
||||
// public static final String URL_REGISTER = "http://124.205.62.213:8080"; //注册
|
||||
// public static final String URL_UPLOAD = "http://124.205.62.213:8080"; //用户上报
|
||||
// public static final String URL_FEEDBACK = "http://124.205.62.213:8080"; //用户反馈、Bug反馈
|
||||
// public static final String URL_MAP = "http://124.205.62.213:8080"; //地图绘制
|
||||
// public static final String URL_POI_SEARCH = "http://124.205.62.213:8080"; //搜索
|
||||
// public static final String URL_APK_UPDATE = "http://124.205.62.213:8080"; //APK
|
||||
// public static final String URL_TTS_DOWNLOAD = "http://124.205.62.213:8080"; //TTS
|
||||
// public static final String URL_MAP_TRAFFIC = "http://124.205.62.213:8080"; //地图路况
|
||||
// public static final String URL_TRAFFIC = "http://124.205.62.213:8080"; //语音
|
||||
// public static final String URL_CURCITY = "http://engine.tuyulbs.com/car"; //经纬度获取城市ID
|
||||
// public static final String URL_REGISTER = "http://124.205.62.213:8080" //注册
|
||||
// public static final String URL_UPLOAD = "http://124.205.62.213:8080" //用户上报
|
||||
// public static final String URL_FEEDBACK = "http://124.205.62.213:8080" //用户反馈、Bug反馈
|
||||
// public static final String URL_MAP = "http://124.205.62.213:8080" //地图绘制
|
||||
// public static final String URL_POI_SEARCH = "http://124.205.62.213:8080" //搜索
|
||||
// public static final String URL_APK_UPDATE = "http://124.205.62.213:8080" //APK
|
||||
// public static final String URL_TTS_DOWNLOAD = "http://124.205.62.213:8080" //TTS
|
||||
// public static final String URL_MAP_TRAFFIC = "http://124.205.62.213:8080" //地图路况
|
||||
// public static final String URL_TRAFFIC = "http://124.205.62.213:8080" //语音
|
||||
// public static final String URL_CURCITY = "http://engine.tuyulbs.com/car" //经纬度获取城市ID
|
||||
//Demo地址
|
||||
// public static final String URL_REGISTER = "http://demo.a-traffic.com:8081"; //注册
|
||||
// public static final String URL_UPLOAD = "http://demo.a-traffic.com:8080"; //用户上报
|
||||
// public static final String URL_FEEDBACK = "http://demo.a-traffic.com:8080"; //用户反馈、Bug反馈
|
||||
// public static final String URL_MAP = "http://demo.a-traffic.com:8080"; //地图绘制
|
||||
// public static final String URL_POI_SEARCH = "http://demo.a-traffic.com:8082"; //搜索
|
||||
// public static final String URL_APK_UPDATE = "http://demo.a-traffic.com:8082"; //APK
|
||||
// public static final String URL_TTS_DOWNLOAD = "http://demo.a-traffic.com:8082"; //TTS
|
||||
// public static final String URL_MAP_TRAFFIC = "http://demo.a-traffic.com:8081"; //地图路况
|
||||
// public static final String URL_TRAFFIC = "http://demo.a-traffic.com:8081"; //语音
|
||||
// public static final String URL_CURCITY = "http://demo.a-traffic.com/poi"; //经纬度获取城市ID
|
||||
// public static final String URL_REGISTER = "http://demo.a-traffic.com:8081" //注册
|
||||
// public static final String URL_UPLOAD = "http://demo.a-traffic.com:8080" //用户上报
|
||||
// public static final String URL_FEEDBACK = "http://demo.a-traffic.com:8080" //用户反馈、Bug反馈
|
||||
// public static final String URL_MAP = "http://demo.a-traffic.com:8080" //地图绘制
|
||||
// public static final String URL_POI_SEARCH = "http://demo.a-traffic.com:8082" //搜索
|
||||
// public static final String URL_APK_UPDATE = "http://demo.a-traffic.com:8082" //APK
|
||||
// public static final String URL_TTS_DOWNLOAD = "http://demo.a-traffic.com:8082" //TTS
|
||||
// public static final String URL_MAP_TRAFFIC = "http://demo.a-traffic.com:8081" //地图路况
|
||||
// public static final String URL_TRAFFIC = "http://demo.a-traffic.com:8081" //语音
|
||||
// public static final String URL_CURCITY = "http://demo.a-traffic.com/poi" //经纬度获取城市ID
|
||||
const val URL_MAPDATADOWNLOAD = "http://192.168.0.86:8080"
|
||||
const val URL_LIUSHJ_TEST = "http://192.168.0.18:8080"
|
||||
|
||||
//正式地址
|
||||
// public static final String URL_REGISTER = "http://app1.a-traffic.com:8082"; //注册
|
||||
// public static final String URL_REGISTER = "http://app1.a-traffic.com:8082" //注册
|
||||
const val URL_UPLOAD = "http://app1.a-traffic.com:8081" //用户上报
|
||||
const val URL_FEEDBACK = "http://app1.a-traffic.com:8083" //用户反馈、Bug反馈
|
||||
const val URL_MAP = "http://app1.a-traffic.com:8084" //地图绘制
|
||||
@@ -75,7 +75,7 @@ object Constant {
|
||||
const val URL_TTS_DOWNLOAD = "http://app2.a-traffic.com:8084" //TTS
|
||||
const val URL_MAP_TRAFFIC = "http://app2.a-traffic.com:8085" //地图路况
|
||||
|
||||
// public static final String URL_TRAFFIC = "http://app0.a-traffic.com:8082"; //语音
|
||||
// public static final String URL_TRAFFIC = "http://app0.a-traffic.com:8082" //语音
|
||||
const val URL_CURCITY = "http://app0.a-traffic.com:8081/cgi-bin" //经纬度获取城市ID
|
||||
|
||||
//Message值从0x200开始??
|
||||
@@ -107,7 +107,7 @@ object Constant {
|
||||
const val ACT_REQ_NEWCNL = MSG_BASE + 24
|
||||
const val ACT_REQ_ADDCH = MSG_BASE + 25
|
||||
|
||||
// public final static int ACT_REQ_MAP = MSG_BASE + 23;
|
||||
// public final static int ACT_REQ_MAP = MSG_BASE + 23
|
||||
const val MSG_NET_TIMEOUT = MSG_BASE + 26
|
||||
const val MSG_EXPORT = MSG_BASE + 27
|
||||
const val MSG_POI_CANCEL = MSG_BASE + 28
|
||||
@@ -160,23 +160,23 @@ object Constant {
|
||||
}
|
||||
var nameChar =
|
||||
ToDBC(name).toCharArray()
|
||||
if (nameChar == null || nameChar.size <= 1) {
|
||||
if (nameChar.size <= 1) {
|
||||
return null
|
||||
}
|
||||
var isNum = false
|
||||
var length = -1
|
||||
for (i in nameChar.indices) {
|
||||
if (isNum == false && isNum(
|
||||
if (!isNum && isNum(
|
||||
nameChar[i].toString()
|
||||
) == true
|
||||
)
|
||||
) {
|
||||
if (i == 0) {
|
||||
return null
|
||||
}
|
||||
isNum = true
|
||||
} else if (isNum == true && isNum(
|
||||
} else if (isNum && !isNum(
|
||||
nameChar[i].toString()
|
||||
) == false
|
||||
)
|
||||
) {
|
||||
length = i
|
||||
break
|
||||
@@ -213,7 +213,7 @@ object Constant {
|
||||
for (i in c.indices) {
|
||||
if (c[i] == '\u3000') {
|
||||
c[i] = ' '
|
||||
} else if (c[i] > '\uFF00' && c[i] < '\uFF5F') {
|
||||
} else if (c[i] in '!'..'~') {
|
||||
c[i] = (c[i] - 65248)
|
||||
}
|
||||
}
|
||||
@@ -277,7 +277,7 @@ object Constant {
|
||||
|
||||
@JvmStatic
|
||||
fun getWorkingDirectory(context: Context): String {
|
||||
var res: String? = null
|
||||
var res: String?
|
||||
if (Environment.getExternalStorageState() ==
|
||||
Environment.MEDIA_MOUNTED
|
||||
) {
|
||||
@@ -316,7 +316,7 @@ object Constant {
|
||||
).versionName
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
|
||||
//e.printStackTrace();
|
||||
//e.printStackTrace()
|
||||
}
|
||||
return "V" + version + "自研版"
|
||||
}
|
||||
@@ -413,7 +413,7 @@ object Constant {
|
||||
val items =
|
||||
arrayOf<CharSequence>("开始导航", "模拟导航", "路线详情", "导航设置", "语音设置")
|
||||
val dialog: Dialog = AlertDialog.Builder(act).setTitle("导航")
|
||||
.setItems(items) { dialog, which ->
|
||||
.setItems(items) { _, which ->
|
||||
when (which) {
|
||||
// 0 -> CommonController.instance.naviController?.startNavi(false)
|
||||
// 1 -> CommonController.instance.naviController?.startNavi(true)
|
||||
@@ -422,7 +422,7 @@ object Constant {
|
||||
// ) {
|
||||
// getRouteBookDialog(act)
|
||||
// .show()
|
||||
// //Toast.makeText(act, "路线详情", Toast.LENGTH_SHORT).show();
|
||||
// //Toast.makeText(act, "路线详情", Toast.LENGTH_SHORT).show()
|
||||
// } else {
|
||||
// //先定位 -- 在路线计算 -- 在显示
|
||||
// CommonController.instance
|
||||
@@ -451,8 +451,8 @@ object Constant {
|
||||
) as LinearLayout
|
||||
initRouteSetting(act, layout)
|
||||
return AlertDialog.Builder(act).setView(layout).setTitle("导航设置")
|
||||
.setNegativeButton("返回") { dialog, which -> getNaviDialog(act).show() }
|
||||
.setPositiveButton("确定") { paramDialogInterface, paramInt ->
|
||||
.setNegativeButton("返回") { _, _ -> getNaviDialog(act).show() }
|
||||
.setPositiveButton("确定") { _, _ ->
|
||||
// CommonController.instance.naviController?.reSetRoute()
|
||||
}
|
||||
.create()
|
||||
@@ -461,8 +461,8 @@ object Constant {
|
||||
fun getExitDialog(act: Activity): Dialog {
|
||||
return AlertDialog.Builder(act).setTitle("注意!")
|
||||
.setMessage("确定要退出吗?")
|
||||
.setPositiveButton("确定") { dialog, which -> act.finish() }
|
||||
.setNegativeButton("取消") { dialog, which -> }.create()
|
||||
.setPositiveButton("确定") { _, _ -> act.finish() }
|
||||
.setNegativeButton("取消") { _, _ -> }.create()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -500,7 +500,7 @@ object Constant {
|
||||
context: Context?,
|
||||
layoutRouteSet: LinearLayout
|
||||
) {
|
||||
// LinearLayout layout = (LinearLayout) LayoutInflater.from(mContext).inflate(R.layout.dialog_routing_set, null);
|
||||
// LinearLayout layout = (LinearLayout) LayoutInflater.from(mContext).inflate(R.layout.dialog_routing_set, null)
|
||||
val rg_routing_model =
|
||||
layoutRouteSet.findViewById(R.id.rg_routing_set) as RadioGroup
|
||||
when (mNavParams.getRoutingModel()) {
|
||||
@@ -602,36 +602,36 @@ object Constant {
|
||||
private val mSubCategoryList: List<SubCategory>? = null
|
||||
|
||||
// public static void getCategorySettingDialog(final Context context){
|
||||
// final ApplicationEx mApplication = (ApplicationEx) context.getApplicationContext();
|
||||
// final List<Category> categoryList;
|
||||
// int urId = CommonController.getInstance().getSettingService().getUpdateRegion();
|
||||
// final ApplicationEx mApplication = (ApplicationEx) context.getApplicationContext()
|
||||
// final List<Category> categoryList
|
||||
// int urId = CommonController.getInstance().getSettingService().getUpdateRegion()
|
||||
// try {
|
||||
// categoryList = CommonController.getInstance().getINavigationCore().getCatDataByDA(urId);
|
||||
// categoryList = CommonController.getInstance().getINavigationCore().getCatDataByDA(urId)
|
||||
// if(categoryList != null && categoryList.size() > 0){
|
||||
// CharSequence[] items = new CharSequence[categoryList.size()];
|
||||
// for(int i = 0; i < categoryList.size(); i++){
|
||||
// items[i] = (CharSequence) categoryList.get(i).getCatName();
|
||||
// CharSequence[] items = new CharSequence[categoryList.size()]
|
||||
// for(int i = 0 i < categoryList.size() i++){
|
||||
// items[i] = (CharSequence) categoryList.get(i).getCatName()
|
||||
// }
|
||||
// Dialog urDialog = new AlertDialog.Builder((Activity) context).setTitle("按类别搜索")
|
||||
// .setItems(items, new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(DialogInterface dialog, int which) {
|
||||
// mSubCategoryList = categoryList.get(which).getSubCategory();
|
||||
// CharSequence[] subItems = new CharSequence[mSubCategoryList.size()];
|
||||
// for(int i = 0; i < mSubCategoryList.size(); i++){
|
||||
// subItems[i] = mSubCategoryList.get(i).getCatName();
|
||||
// mSubCategoryList = categoryList.get(which).getSubCategory()
|
||||
// CharSequence[] subItems = new CharSequence[mSubCategoryList.size()]
|
||||
// for(int i = 0 i < mSubCategoryList.size() i++){
|
||||
// subItems[i] = mSubCategoryList.get(i).getCatName()
|
||||
// }
|
||||
// getSubCategorySettingDialog(context, subItems);
|
||||
// getSubCategorySettingDialog(context, subItems)
|
||||
// }
|
||||
// })
|
||||
// .create();
|
||||
// urDialog.show();
|
||||
// .create()
|
||||
// urDialog.show()
|
||||
// }else{
|
||||
// Constant.getDialog((Activity) context, "获取类别列表失败").show();
|
||||
// Constant.getDialog((Activity) context, "获取类别列表失败").show()
|
||||
// }
|
||||
// } catch (RemoteException e) {
|
||||
//
|
||||
// e.printStackTrace();
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }
|
||||
private val mSubCategoryName: String? = null
|
||||
@@ -640,46 +640,44 @@ object Constant {
|
||||
// Dialog dialog = new AlertDialog.Builder((Activity) context).setTitle("请选择搜索类别")
|
||||
// .setItems(subItems, new DialogInterface.OnClickListener() {
|
||||
//
|
||||
// ApplicationEx mApplication = (ApplicationEx) context.getApplicationContext();
|
||||
// ApplicationEx mApplication = (ApplicationEx) context.getApplicationContext()
|
||||
// @Override
|
||||
// public void onClick(DialogInterface dialog, int which) {
|
||||
// mSubCategoryName = mSubCategoryList.get(which).getCatName();
|
||||
// DataStorageManager.getInstance().setPoiKey(mSubCategoryName);
|
||||
// SearchManager.GetInstance().StartPOISearch(context, 1, mSubCategoryName, mSubCategoryList.get(which).getKindId(), CommonController.getInstance().getSearchHandler().obtainMessage(MapActivity.MSG_POI_RES));
|
||||
// mApplication.setIsSearchStatInput(false);
|
||||
// mSubCategoryName = mSubCategoryList.get(which).getCatName()
|
||||
// DataStorageManager.getInstance().setPoiKey(mSubCategoryName)
|
||||
// SearchManager.GetInstance().StartPOISearch(context, 1, mSubCategoryName, mSubCategoryList.get(which).getKindId(), CommonController.getInstance().getSearchHandler().obtainMessage(MapActivity.MSG_POI_RES))
|
||||
// mApplication.setIsSearchStatInput(false)
|
||||
// }
|
||||
// })
|
||||
// .setNegativeButton("返回", new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(DialogInterface paramDialogInterface, int paramInt) {
|
||||
// getCategorySettingDialog(context);
|
||||
// getCategorySettingDialog(context)
|
||||
// }
|
||||
// })
|
||||
// .setOnCancelListener(new OnCancelListener() {
|
||||
//
|
||||
// @Override
|
||||
// public void onCancel(DialogInterface paramDialogInterface) {
|
||||
// getCategorySettingDialog(context);
|
||||
// getCategorySettingDialog(context)
|
||||
// }
|
||||
// })
|
||||
// .create();
|
||||
// dialog.show();
|
||||
// .create()
|
||||
// dialog.show()
|
||||
// }
|
||||
fun getGpsDialog(act: Activity): Dialog {
|
||||
return AlertDialog.Builder(act).setTitle("提高“我的位置”精度")
|
||||
.setMessage("如需获取更精确的位置服务,请您执行以下操作:\n\n在位置设置中打开GPS")
|
||||
.setPositiveButton("设置") { dialog, which ->
|
||||
.setPositiveButton("设置") { _, _ ->
|
||||
try {
|
||||
val gpsOptionsIntent =
|
||||
Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
|
||||
act.startActivity(gpsOptionsIntent)
|
||||
} catch (ex: Exception) {
|
||||
}
|
||||
}.setNegativeButton("取消") { dialog, which -> }
|
||||
.setOnKeyListener { dialog, keyCode, event ->
|
||||
if (keyCode == KeyEvent.KEYCODE_SEARCH) {
|
||||
true
|
||||
} else false
|
||||
}.setNegativeButton("取消") { _, _ -> }
|
||||
.setOnKeyListener { _, keyCode, _ ->
|
||||
keyCode == KeyEvent.KEYCODE_SEARCH
|
||||
}.create()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.zhidaoauto.map.sdk.inner.utils
|
||||
|
||||
import kotlin.math.*
|
||||
|
||||
class DistanceHelper {
|
||||
private val EARTH_RADIUS = 6378137.0
|
||||
|
||||
@@ -13,23 +15,23 @@ class DistanceHelper {
|
||||
/// <returns>返回一个范围的4个点,最小纬度和纬度,最大经度和纬度</returns>
|
||||
// public static PositionModel FindNeighPosition(double longitude, double latitude, double distance) {
|
||||
// //先计算查询点的经纬度范围
|
||||
// double r = 6378.137;//地球半径千米
|
||||
// double dis = distance;//千米距离
|
||||
// double dlng = 2 * Math.asin(Math.sin(dis / (2 * r)) / Math.cos(latitude * Math.PI / 180));
|
||||
// dlng = dlng * 180 / Math.PI;//角度转为弧度
|
||||
// double dlat = dis / r;
|
||||
// dlat = dlat * 180 / Math.PI;
|
||||
// double minlat = latitude - dlat;
|
||||
// double maxlat = latitude + dlat;
|
||||
// double minlng = longitude - dlng;
|
||||
// double maxlng = longitude + dlng;
|
||||
// double r = 6378.137//地球半径千米
|
||||
// double dis = distance//千米距离
|
||||
// double dlng = 2 * Math.asin(Math.sin(dis / (2 * r)) / Math.cos(latitude * Math.PI / 180))
|
||||
// dlng = dlng * 180 / Math.PI//角度转为弧度
|
||||
// double dlat = dis / r
|
||||
// dlat = dlat * 180 / Math.PI
|
||||
// double minlat = latitude - dlat
|
||||
// double maxlat = latitude + dlat
|
||||
// double minlng = longitude - dlng
|
||||
// double maxlng = longitude + dlng
|
||||
// return new PositionModel
|
||||
// {
|
||||
// MinLat = minlat,
|
||||
// MaxLat = maxlat,
|
||||
// MinLng = minlng,
|
||||
// MaxLng = maxlng
|
||||
// } ;
|
||||
// }
|
||||
// }
|
||||
/// <summary>
|
||||
/// 计算两点位置的距离,返回两点的距离,单位:公里或千米
|
||||
@@ -42,14 +44,14 @@ class DistanceHelper {
|
||||
/// <returns>返回两点的距离,单位:公里或千米</returns>
|
||||
// public static double GetDistance(double lng1, double lat1, double lng2, double lat2) {
|
||||
// //地球半径,单位米
|
||||
// double radLat1 = Rad(lat1);
|
||||
// double radLng1 = Rad(lng1);
|
||||
// double radLat2 = Rad(lat2);
|
||||
// double radLng2 = Rad(lng2);
|
||||
// double a = radLat2 - radLat1;
|
||||
// double b = radLng2 - radLng1;
|
||||
// double result = 2 * Math.Asin(Math.Sqrt(Math.Pow(Math.Sin(a / 2), 2) + Math.Cos(radLat1) * Math.Cos(radLat2) * Math.Pow(Math.Sin(b / 2), 2))) * EARTH_RADIUS;
|
||||
// return result / 1000;
|
||||
// double radLat1 = Rad(lat1)
|
||||
// double radLng1 = Rad(lng1)
|
||||
// double radLat2 = Rad(lat2)
|
||||
// double radLng2 = Rad(lng2)
|
||||
// double a = radLat2 - radLat1
|
||||
// double b = radLng2 - radLng1
|
||||
// double result = 2 * Math.Asin(Math.Sqrt(Math.Pow(Math.Sin(a / 2), 2) + Math.Cos(radLat1) * Math.Cos(radLat2) * Math.Pow(Math.Sin(b / 2), 2))) * EARTH_RADIUS
|
||||
// return result / 1000
|
||||
// }
|
||||
/// <summary>
|
||||
/// 经纬度转化成弧度
|
||||
@@ -69,7 +71,7 @@ class DistanceHelper {
|
||||
/// <param name="lat2"></param>
|
||||
/// <returns></returns>
|
||||
// 有问题
|
||||
fun GetDirection(lng1: Double, lat1: Double, lng2: Double, lat2: Double): Double {
|
||||
fun getDirection(lng1: Double, lat1: Double, lng2: Double, lat2: Double): Double {
|
||||
//地球半径,单位米
|
||||
val radLng1 = Rad(lng1)
|
||||
val radLat1 = Rad(lat1)
|
||||
@@ -78,10 +80,10 @@ class DistanceHelper {
|
||||
val a = Rad(90 - lat2)
|
||||
val b = Rad(90 - lat1)
|
||||
val c = Rad(lng2 - lng1)
|
||||
val cos_c = Math.cos(b) * Math.cos(a) + Math.sin(b) * Math.sin(a) * Math.cos(c)
|
||||
val sin_c = Math.sqrt(1 - Math.pow(cos_c, 2.0))
|
||||
val sin_a = Math.sin(Math.sin(b) * Math.sin(c) / sin_c)
|
||||
val Azimuth = Math.asin(sin_a) * 180 / Math.PI
|
||||
val cos_c = cos(b) * cos(a) + sin(b) * sin(a) * cos(c)
|
||||
val sin_c = sqrt(1 - cos_c.pow(2.0))
|
||||
val sin_a = sin(sin(b) * sin(c) / sin_c)
|
||||
val Azimuth = asin(sin_a) * 180 / Math.PI
|
||||
val x = lng2 - lng1 //经度
|
||||
val y = lat2 - lat1 //纬度
|
||||
return if (x > 0 && y > 0) //第一象限
|
||||
@@ -94,7 +96,7 @@ class DistanceHelper {
|
||||
{
|
||||
180 - Azimuth
|
||||
}
|
||||
// return quadrant(lat1, lng1, lat2, lng2, Azimuth);
|
||||
// return quadrant(lat1, lng1, lat2, lng2, Azimuth)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -106,21 +108,21 @@ class DistanceHelper {
|
||||
/// <param name="lat2"></param>
|
||||
/// <returns></returns>
|
||||
// 有问题
|
||||
fun GetDirection2(lng1: Double, lat1: Double, lng2: Double, lat2: Double): Double {
|
||||
//double reslt1 = Math.Tan(Rad(90));
|
||||
//double reslt = Math.Atan(reslt1) *180/ Math.PI;
|
||||
fun getDirection2(lng1: Double, lat1: Double, lng2: Double, lat2: Double): Double {
|
||||
//double reslt1 = Math.Tan(Rad(90))
|
||||
//double reslt = Math.Atan(reslt1) *180/ Math.PI
|
||||
val radLng1 = Rad(lng1)
|
||||
val radLat1 = Rad(lat1)
|
||||
val radLng2 = Rad(lng2)
|
||||
val radLat2 = Rad(lat2)
|
||||
//double a = radLng2 - radLng1;
|
||||
//double b = radLat2 - radLat1;
|
||||
//double c = Math.Cos(lat2);
|
||||
//double a = radLng2 - radLng1
|
||||
//double b = radLat2 - radLat1
|
||||
//double c = Math.Cos(lat2)
|
||||
val a = Rad(lng2 - lng1)
|
||||
val b = Rad(lat2 - lat1)
|
||||
val c = Math.cos(radLat2)
|
||||
val result1 = Math.tan(a * c / b)
|
||||
val result = Math.atan(result1) * 180f / Math.PI
|
||||
val c = cos(radLat2)
|
||||
val result1 = tan(a * c / b)
|
||||
val result = atan(result1) * 180f / Math.PI
|
||||
val x = lng2 - lng1 //经度
|
||||
val y = lat2 - lat1 //纬度
|
||||
return if (x > 0 && y > 0) //第一象限
|
||||
@@ -135,7 +137,7 @@ class DistanceHelper {
|
||||
}
|
||||
}
|
||||
|
||||
fun GetAzimuth(
|
||||
fun getAzimuth(
|
||||
lon1: Double, lat1: Double, lon2: Double,
|
||||
lat2: Double
|
||||
): Double {
|
||||
@@ -147,10 +149,10 @@ class DistanceHelper {
|
||||
lat2 = Rad(lat2)
|
||||
lon1 = Rad(lon1)
|
||||
lon2 = Rad(lon2)
|
||||
var azimuth = Math.sin(lat1) * Math.sin(lat2) + (Math.cos(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1))
|
||||
azimuth = Math.sqrt(1.0 - azimuth * azimuth)
|
||||
azimuth = Math.cos(lat2) * Math.sin(lon2 - lon1) / azimuth
|
||||
azimuth = Math.asin(azimuth) * 180f / Math.PI
|
||||
var azimuth = sin(lat1) * sin(lat2) + (cos(lat1) * cos(lat2) * cos(lon2 - lon1))
|
||||
azimuth = sqrt(1.0 - azimuth * azimuth)
|
||||
azimuth = cos(lat2) * sin(lon2 - lon1) / azimuth
|
||||
azimuth = asin(azimuth) * 180f / Math.PI
|
||||
if (java.lang.Double.isNaN(azimuth)) {
|
||||
azimuth = if (lon1 < lon2) {
|
||||
90.0
|
||||
@@ -165,59 +167,59 @@ class DistanceHelper {
|
||||
|
||||
// 有问题
|
||||
fun getAngle(lon1: Double, lat1: Double, lon2: Double, lat2: Double): Float {
|
||||
val x = lat1 - lat2;
|
||||
val y = lon1 - lon2;
|
||||
var angle = -1f;
|
||||
val x = lat1 - lat2
|
||||
val y = lon1 - lon2
|
||||
var angle = -1f
|
||||
if (y == 0.0 && x > 0.0)
|
||||
angle = 0.0f;
|
||||
angle = 0.0f
|
||||
if (y == 0.0 && x < 0.0)
|
||||
angle = 180.0f;
|
||||
angle = 180.0f
|
||||
if (x == 0.0 && y > 0.0)
|
||||
angle = 90.0f;
|
||||
angle = 90.0f
|
||||
if (x == 0.0 && y < 0.0)
|
||||
angle = 270.0f;
|
||||
angle = 270.0f
|
||||
if (angle == -1f) {
|
||||
val dislon = get_distance(lon1, lat2, lon2, lat2);
|
||||
val dislat = get_distance(lon2, lat1, lon2, lat2);
|
||||
val dislon = get_distance(lon1, lat2, lon2, lat2)
|
||||
val dislat = get_distance(lon2, lat1, lon2, lat2)
|
||||
if (x > 0 && y > 0)
|
||||
angle = (Math.atan2(dislon, dislat) / Math.PI * 180.0).toFloat();
|
||||
angle = (Math.atan2(dislon, dislat) / Math.PI * 180.0).toFloat()
|
||||
if (x < 0 && y > 0)
|
||||
angle = (Math.atan2(dislat, dislon) / Math.PI * 180 + 90).toFloat();
|
||||
angle = (Math.atan2(dislat, dislon) / Math.PI * 180 + 90).toFloat()
|
||||
if (x < 0 && y < 0)
|
||||
angle = (Math.atan2(dislon, dislat) / Math.PI * 180 + 180).toFloat();
|
||||
angle = (Math.atan2(dislon, dislat) / Math.PI * 180 + 180).toFloat()
|
||||
if (x > 0 && y < 0)
|
||||
angle = (Math.atan2(dislat, dislon) / Math.PI * 180 + 270).toFloat();
|
||||
angle = (Math.atan2(dislat, dislon) / Math.PI * 180 + 270).toFloat()
|
||||
}
|
||||
return angle;
|
||||
return angle
|
||||
}
|
||||
|
||||
fun HaverSin(thera: Double): Double {
|
||||
val v = Math.sin(thera / 2);
|
||||
return v * v;
|
||||
val v = Math.sin(thera / 2)
|
||||
return v * v
|
||||
}
|
||||
|
||||
//角度转换为弧度
|
||||
fun ConvertDegreesToRadians(degrees: Double): Double {
|
||||
return degrees * Math.PI / 180f;
|
||||
return degrees * Math.PI / 180f
|
||||
}
|
||||
|
||||
//弧度转换为角度
|
||||
fun ConvertRadiansToDegrees(radian: Double): Double {
|
||||
return radian * 180.0 / Math.PI;
|
||||
return radian * 180.0 / Math.PI
|
||||
}
|
||||
|
||||
//计算两个经纬度坐标间的距离(单位:米)
|
||||
//参数:lon1为经度1;lat1为纬度1;lon2为经度2;lat2为纬度2
|
||||
fun get_distance(lon1: Double, lat1: Double, lon2: Double, lat2: Double): Double {
|
||||
var lat1 = ConvertDegreesToRadians(lat1);
|
||||
var lon1 = ConvertDegreesToRadians(lon1);
|
||||
var lat2 = ConvertDegreesToRadians(lat2);
|
||||
var lon2 = ConvertDegreesToRadians(lon2);
|
||||
val lat1 = ConvertDegreesToRadians(lat1)
|
||||
val lon1 = ConvertDegreesToRadians(lon1)
|
||||
val lat2 = ConvertDegreesToRadians(lat2)
|
||||
val lon2 = ConvertDegreesToRadians(lon2)
|
||||
|
||||
val vLon = Math.abs(lon1 - lon2);
|
||||
val vLat = Math.abs(lat1 - lat2);
|
||||
val h = HaverSin(vLat) + Math.cos(lat1) * Math.cos(lat2) * HaverSin(vLon);
|
||||
val distance = 2 * 6371 * Math.asin(Math.sqrt(h));
|
||||
return distance * 1000;
|
||||
val vLon = abs(lon1 - lon2)
|
||||
val vLat = abs(lat1 - lat2)
|
||||
val h = HaverSin(vLat) + cos(lat1) * cos(lat2) * HaverSin(vLon)
|
||||
val distance = 2 * 6371 * asin(sqrt(h))
|
||||
return distance * 1000
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ object FileUtils {
|
||||
|
||||
fun copyDirect(assetManager: AssetManager, assetDir: String, dir: String): Boolean {
|
||||
|
||||
val mWorkingPath = File(dir);
|
||||
val mWorkingPath = File(dir)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "assetop--copyDirect:parent:${dir},${mWorkingPath.exists()}")
|
||||
}
|
||||
@@ -30,10 +30,10 @@ object FileUtils {
|
||||
if (!mWorkingPath.exists()) {
|
||||
mWorkingPath.mkdirs()
|
||||
}
|
||||
var files: Array<String>?
|
||||
val files: Array<String>?
|
||||
try {
|
||||
// 获得Assets文件夹下指定文件夹一共有多少文件
|
||||
files = assetManager.list(assetDir);
|
||||
files = assetManager.list(assetDir)
|
||||
} catch (e1: IOException) {
|
||||
Log.e(TAG, "assetop-e1", e1)
|
||||
return false
|
||||
@@ -41,28 +41,28 @@ object FileUtils {
|
||||
if(files == null || files.isEmpty()){
|
||||
return false
|
||||
}
|
||||
var result = true;
|
||||
var result = true
|
||||
for (i in 0 until files.size) {
|
||||
val finalI = i
|
||||
try {
|
||||
// 获得每个文件的名字
|
||||
val fileName = files[finalI];
|
||||
val fileName = files[finalI]
|
||||
|
||||
val outFile = File("${mWorkingPath}/${fileName}");
|
||||
val outFile = File("${mWorkingPath}/${fileName}")
|
||||
// 判断文件是否存在
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "assetop--${outFile.name},${outFile.exists()}")
|
||||
}
|
||||
val assetSecondName = "${assetDir}/${outFile.name}"
|
||||
val secondList = assetManager.list(assetSecondName)
|
||||
if (secondList != null && secondList.size > 0) {
|
||||
if (secondList != null && secondList.isNotEmpty()) {
|
||||
result = copyDirect(assetManager, assetSecondName, "${dir}/${outFile.name}")
|
||||
} else if (!outFile.exists()) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "assetop--exists:false,path:${outFile.absolutePath}")
|
||||
}
|
||||
try {
|
||||
outFile.createNewFile();
|
||||
outFile.createNewFile()
|
||||
}catch (e1:Exception){
|
||||
e1.printStackTrace()
|
||||
if(!outFile.exists()){
|
||||
@@ -70,19 +70,19 @@ object FileUtils {
|
||||
// continue
|
||||
}
|
||||
}
|
||||
val out = FileOutputStream(outFile);
|
||||
var inputStream: InputStream? = null;
|
||||
val out = FileOutputStream(outFile)
|
||||
var inputStream: InputStream? = null
|
||||
try{
|
||||
if (0 != assetDir.length) {
|
||||
inputStream = assetManager.open(assetDir + "/" + fileName);
|
||||
if (assetDir.isNotEmpty()) {
|
||||
inputStream = assetManager.open("$assetDir/$fileName")
|
||||
}else {
|
||||
inputStream = assetManager.open(fileName);
|
||||
inputStream = assetManager.open(fileName)
|
||||
}
|
||||
// Transfer bytes from in to out
|
||||
val buf = ByteArray(2048)
|
||||
var len: Int = -1
|
||||
while (inputStream?.read(buf).also { len = it!! } != -1) {
|
||||
out.write(buf, 0, len);
|
||||
var len: Int
|
||||
while (inputStream.read(buf).also { len = it } != -1) {
|
||||
out.write(buf, 0, len)
|
||||
}
|
||||
}catch (e2:Exception){
|
||||
|
||||
@@ -113,10 +113,10 @@ object FileUtils {
|
||||
// 如果dir不以文件分隔符结尾,自动添加文件分隔符
|
||||
|
||||
var dir = dir
|
||||
if (!dir.endsWith(File.separator)) dir = dir + File.separator
|
||||
if (!dir.endsWith(File.separator)) dir += File.separator
|
||||
val dirFile = File(dir)
|
||||
// 如果dir对应的文件不存在,或者不是一个目录,则退出
|
||||
if (dirFile == null || !dirFile.exists() || !dirFile.isDirectory) {
|
||||
if (!dirFile.exists() || !dirFile.isDirectory) {
|
||||
return false
|
||||
}
|
||||
var flag = true
|
||||
@@ -139,11 +139,7 @@ object FileUtils {
|
||||
return false
|
||||
}
|
||||
// 删除当前目录
|
||||
return if (dirFile.delete()) {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
return dirFile.delete()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,11 +153,7 @@ object FileUtils {
|
||||
val file = File(fileName)
|
||||
// 如果文件路径所对应的文件存在,并且是一个文件,则直接删除
|
||||
return if (file.exists() && file.isFile) {
|
||||
if (file.delete()) {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
file.delete()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
@@ -186,13 +178,10 @@ object FileUtils {
|
||||
|
||||
fun saveBitmap(bitmap: Bitmap, name: String) {
|
||||
val sdf = SimpleDateFormat("yyyyMMddHHmmss")
|
||||
if (null == bitmap) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
var path = "${getDirectory()}/${name}"
|
||||
val path = "${getDirectory()}/${name}"
|
||||
val fos = FileOutputStream(path)
|
||||
val b = bitmap?.compress(Bitmap.CompressFormat.PNG, 100, fos)
|
||||
val b = bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos)
|
||||
try {
|
||||
fos.flush()
|
||||
} catch (e: IOException) {
|
||||
@@ -210,17 +199,17 @@ object FileUtils {
|
||||
}
|
||||
|
||||
fun isSame(assetManager: AssetManager, assetDir: String, dir: String): Boolean {
|
||||
var fileDir = File(dir)
|
||||
var fileAsset = assetManager.list(assetDir)
|
||||
val fileDir = File(dir)
|
||||
val fileAsset = assetManager.list(assetDir)
|
||||
if(fileDir.list() == null || fileDir.list().isEmpty() || fileAsset ==null || fileAsset.isEmpty()){
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
var count = 0
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "isSame--fileAsset.size:${fileAsset.size} fileDir.list().size:${fileDir.list().size}")
|
||||
}
|
||||
if (fileDir.isDirectory && fileAsset.size == fileDir.list().size) {
|
||||
val subDirFile = fileDir.listFiles().toMutableList()
|
||||
if (fileDir.isDirectory && fileAsset.size == fileDir.list()!!.size) {
|
||||
val subDirFile = fileDir.listFiles()!!.toMutableList()
|
||||
for (path in fileAsset) {
|
||||
val file = File(path)
|
||||
for (dirFile in subDirFile) {
|
||||
@@ -254,24 +243,24 @@ object FileUtils {
|
||||
}
|
||||
|
||||
fun isSameFiles(assetManager: AssetManager, assetDir: String, dir: String): Boolean {
|
||||
var fileAsset = assetManager.list(assetDir)
|
||||
val fileAsset = assetManager.list(assetDir)
|
||||
if (fileAsset == null || fileAsset.isEmpty()){
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
var result = true;
|
||||
var result = true
|
||||
for (i in 0 until fileAsset.size) {
|
||||
val finalI = i
|
||||
try {
|
||||
// 获得每个文件的名字
|
||||
val fileName = fileAsset[finalI];
|
||||
val outFile = File("${dir}/${fileName}");
|
||||
val fileName = fileAsset[finalI]
|
||||
val outFile = File("${dir}/${fileName}")
|
||||
// 判断文件是否存在
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "assetop--${outFile.name},${outFile.isDirectory}")
|
||||
}
|
||||
val assetSecondName = "${assetDir}/${outFile.name}"
|
||||
val secondList = assetManager.list(assetSecondName)
|
||||
if (secondList != null && secondList.size > 0) {
|
||||
if (secondList != null && secondList.isNotEmpty()) {
|
||||
result = isSameFiles(assetManager, assetSecondName, outFile.absolutePath)
|
||||
if(!result){
|
||||
return false
|
||||
@@ -281,9 +270,9 @@ object FileUtils {
|
||||
return false
|
||||
} else {
|
||||
//判断大小
|
||||
var inputStream: InputStream? = assetManager.open( "${assetDir}/${fileName}")
|
||||
val length = inputStream?.available()
|
||||
inputStream?.close()
|
||||
val inputStream: InputStream = assetManager.open( "${assetDir}/${fileName}")
|
||||
val length = inputStream.available()
|
||||
inputStream.close()
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.w(TAG, "assetop--isSameFiles-length:${length},outFile:${outFile.length().toInt()}")
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ object MathUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lonLatPoint != null && lastLonLatPoint != null) {
|
||||
if (lastLonLatPoint != null) {
|
||||
tempAngle = GisGeomTool.getAngleToNorth(
|
||||
getRound(lonLatPoint.longitude) - getRound(lastLonLatPoint!!.longitude),
|
||||
getRound(lonLatPoint.latitude) - getRound(lastLonLatPoint!!.latitude)
|
||||
@@ -285,8 +285,8 @@ object MathUtils {
|
||||
* 根据最近两点距离决定与哪个历史点进行方向匹配
|
||||
*/
|
||||
fun getAngle(pLine: ArrayList<LonLatPoint>, angles: ArrayList<Double>?): Float {
|
||||
var tempAngle = 0.0
|
||||
var index = 0
|
||||
var tempAngle: Double
|
||||
var index: Int
|
||||
var diffValOrigin = 0.0f
|
||||
var diffValCal = 0.0f
|
||||
val lonLatPoint = pLine[pLine.size - 1]
|
||||
@@ -347,7 +347,7 @@ object MathUtils {
|
||||
break
|
||||
}
|
||||
}
|
||||
if (lonLatPoint != null && lastLonLatPoint != null) {
|
||||
if (lastLonLatPoint != null) {
|
||||
tempAngle = GisGeomTool.getAngleToNorth(
|
||||
lonLatPoint.longitude - lastLonLatPoint.longitude,
|
||||
lonLatPoint.latitude - lastLonLatPoint.latitude
|
||||
|
||||
@@ -7,11 +7,11 @@ import java.io.IOException
|
||||
object OperationUtils {
|
||||
|
||||
fun fromRawResource(resId: Int,context: Context?) :ByteArray?{
|
||||
val dis = DataInputStream(context?.getResources()?.openRawResource(resId))
|
||||
val dis = DataInputStream(context?.resources?.openRawResource(resId))
|
||||
var curTotSize = 64 * 1024
|
||||
var totBuffer = ByteArray(curTotSize)
|
||||
val buffer = ByteArray(1024)
|
||||
var size = 0
|
||||
var size: Int
|
||||
var totSize = 0
|
||||
try {
|
||||
while (dis.read(buffer).also { size = it } >= 0) {
|
||||
|
||||
@@ -35,13 +35,11 @@ object Recorder {
|
||||
//是否记录操作日志
|
||||
var isWork = true
|
||||
|
||||
private val comparator = object : Comparator<String?> {
|
||||
override fun compare(o1: String?, o2: String?): Int {
|
||||
return if (!TextUtils.isEmpty(o1)
|
||||
&& !TextUtils.isEmpty(o2)
|
||||
&& o1!!.replace("-","").toLong() < o2!!.replace("-","").toLong()
|
||||
) -1 else 1
|
||||
}
|
||||
private val comparator = Comparator<String?> { o1, o2 ->
|
||||
if (!TextUtils.isEmpty(o1)
|
||||
&& !TextUtils.isEmpty(o2)
|
||||
&& o1!!.replace("-","").toLong() < o2!!.replace("-","").toLong()
|
||||
) -1 else 1
|
||||
}
|
||||
fun add(content: String) {
|
||||
i(DEFAULT_INSTANCE,"${System.currentTimeMillis()},$content")
|
||||
@@ -73,7 +71,7 @@ object Recorder {
|
||||
val path = write(TAG,instance,content)
|
||||
//处理回调逻辑
|
||||
mLastPath?.let{
|
||||
if(!it.equals(path)){
|
||||
if(it != path){
|
||||
//TODO MATT
|
||||
// CommonEventController.instance.dispatchLog(it)
|
||||
//检查是否需要删除文件
|
||||
@@ -93,7 +91,7 @@ object Recorder {
|
||||
if (dir != null) {
|
||||
Log.i(TAG, "checkLog: $dir")
|
||||
val file = File(dir)
|
||||
if (file != null && file.exists()) {
|
||||
if (file.exists()) {
|
||||
val array = file.list()
|
||||
if (array == null || array.size <= 3) {
|
||||
return
|
||||
@@ -113,10 +111,7 @@ object Recorder {
|
||||
|
||||
suspend fun delete(file: File) {
|
||||
if (file.isDirectory) {
|
||||
val list = file.listFiles()
|
||||
if(list == null){
|
||||
return
|
||||
}
|
||||
val list = file.listFiles() ?: return
|
||||
for (f in list) {
|
||||
delete(f)
|
||||
}
|
||||
@@ -129,14 +124,12 @@ object Recorder {
|
||||
|
||||
suspend fun write(fileName:String,instance: String,content: String):String {
|
||||
val dir = dealFilePath(fileName,instance)
|
||||
if (dir != null) {
|
||||
try {
|
||||
val fw = FileWriter("${dir}", true)
|
||||
fw.write("$content\r\n")
|
||||
fw.close()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
try {
|
||||
val fw = FileWriter("$dir", true)
|
||||
fw.write("$content\r\n")
|
||||
fw.close()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return dir
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class SunriseSunset {
|
||||
private double dfT, dfT0, dfTT; // SUNUP.BAS T, T0, TT
|
||||
private double dfV0, dfV1, dfV2; // SUNUP.BAS V0, V1, V2
|
||||
|
||||
private TimeZone tz = TimeZone.getTimeZone("GMT");
|
||||
private final TimeZone tz = TimeZone.getTimeZone("GMT");
|
||||
private double origTimeZone;
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.zhidaoauto.map.sdk.inner.utils
|
||||
import android.content.Context
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController
|
||||
import java.math.BigDecimal
|
||||
import kotlin.math.*
|
||||
|
||||
|
||||
object TransformUtils {
|
||||
@@ -16,23 +17,23 @@ object TransformUtils {
|
||||
|
||||
private fun transformLat(lng: Double, lat: Double): Double {
|
||||
var ret =
|
||||
-100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(
|
||||
Math.abs(lng)
|
||||
-100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * sqrt(
|
||||
abs(lng)
|
||||
)
|
||||
ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0
|
||||
ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0
|
||||
ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0
|
||||
ret += (20.0 * sin(6.0 * lng * PI) + 20.0 * sin(2.0 * lng * PI)) * 2.0 / 3.0
|
||||
ret += (20.0 * sin(lat * PI) + 40.0 * sin(lat / 3.0 * PI)) * 2.0 / 3.0
|
||||
ret += (160.0 * sin(lat / 12.0 * PI) + 320 * sin(lat * PI / 30.0)) * 2.0 / 3.0
|
||||
return ret
|
||||
}
|
||||
|
||||
private fun transformLon(lng: Double, lat: Double): Double {
|
||||
var ret =
|
||||
300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(
|
||||
Math.abs(lng)
|
||||
300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * sqrt(
|
||||
abs(lng)
|
||||
)
|
||||
ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0
|
||||
ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0
|
||||
ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0
|
||||
ret += (20.0 * sin(6.0 * lng * PI) + 20.0 * sin(2.0 * lng * PI)) * 2.0 / 3.0
|
||||
ret += (20.0 * sin(lng * PI) + 40.0 * sin(lng / 3.0 * PI)) * 2.0 / 3.0
|
||||
ret += (150.0 * sin(lng / 12.0 * PI) + 300.0 * sin(lng / 30.0 * PI)) * 2.0 / 3.0
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -58,11 +59,11 @@ object TransformUtils {
|
||||
var dLat = transformLat(wgLon - 105.0, wgLat - 35.0)
|
||||
var dLon = transformLon(wgLon - 105.0, wgLat - 35.0)
|
||||
val radLat = wgLat / 180.0 * PI
|
||||
var magic = Math.sin(radLat)
|
||||
var magic = sin(radLat)
|
||||
magic = 1 - ee * magic * magic
|
||||
val sqrtMagic = Math.sqrt(magic)
|
||||
val sqrtMagic = sqrt(magic)
|
||||
dLat = dLat * 180.0 / (a * (1 - ee) / (magic * sqrtMagic) * PI)
|
||||
dLon = dLon * 180.0 / (a / sqrtMagic * Math.cos(radLat) * PI)
|
||||
dLon = dLon * 180.0 / (a / sqrtMagic * cos(radLat) * PI)
|
||||
mgLat = wgLat + dLat
|
||||
mgLon = wgLon + dLon
|
||||
point[0] = dealRound(mgLon)
|
||||
@@ -86,11 +87,11 @@ object TransformUtils {
|
||||
val x = bd_lon - 0.0065
|
||||
val y = bd_lat - 0.006
|
||||
val z =
|
||||
Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_PI)
|
||||
sqrt(x * x + y * y) - 0.00002 * sin(y * x_PI)
|
||||
val theta =
|
||||
Math.atan2(y, x) - 0.000003 * Math.cos(x * x_PI)
|
||||
val gg_lng = z * Math.cos(theta)
|
||||
val gg_lat = z * Math.sin(theta)
|
||||
atan2(y, x) - 0.000003 * cos(x * x_PI)
|
||||
val gg_lng = z * cos(theta)
|
||||
val gg_lat = z * sin(theta)
|
||||
return doubleArrayOf(dealRound(gg_lng), dealRound(gg_lat))
|
||||
}
|
||||
|
||||
@@ -106,11 +107,11 @@ object TransformUtils {
|
||||
lat: Double,
|
||||
lng: Double
|
||||
): DoubleArray {
|
||||
val z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * x_PI)
|
||||
val z = sqrt(lng * lng + lat * lat) + 0.00002 * sin(lat * x_PI)
|
||||
val theta =
|
||||
Math.atan2(lat, lng) + 0.000003 * Math.cos(lng * x_PI)
|
||||
val bd_lng = z * Math.cos(theta) + 0.0065
|
||||
val bd_lat = z * Math.sin(theta) + 0.006
|
||||
atan2(lat, lng) + 0.000003 * cos(lng * x_PI)
|
||||
val bd_lng = z * cos(theta) + 0.0065
|
||||
val bd_lat = z * sin(theta) + 0.006
|
||||
return doubleArrayOf(dealRound(bd_lng), dealRound(bd_lat))
|
||||
}
|
||||
|
||||
@@ -131,11 +132,11 @@ object TransformUtils {
|
||||
var dlat = transformLat(lng - 105.0, lat - 35.0)
|
||||
var dlng = transformLon(lng - 105.0, lat - 35.0)
|
||||
val radlat = lat / 180.0 * PI
|
||||
var magic = Math.sin(radlat)
|
||||
var magic = sin(radlat)
|
||||
magic = 1.0 - ee * magic * magic
|
||||
val sqrtmagic = Math.sqrt(magic)
|
||||
val sqrtmagic = sqrt(magic)
|
||||
dlat = dlat * 180.0 / (a * (1.0 - ee) / (magic * sqrtmagic) * PI)
|
||||
dlng = dlng * 180.0 / (a / sqrtmagic * Math.cos(radlat) * PI)
|
||||
dlng = dlng * 180.0 / (a / sqrtmagic * cos(radlat) * PI)
|
||||
val mglat = lat + dlat
|
||||
val mglng = lng + dlng
|
||||
doubleArrayOf(dealRound(mglng), dealRound(mglat))
|
||||
@@ -159,11 +160,11 @@ object TransformUtils {
|
||||
var dlat = transformLat(lng - 105.0, lat - 35.0)
|
||||
var dlng = transformLon(lng - 105.0, lat - 35.0)
|
||||
val radlat = lat / 180.0 * PI
|
||||
var magic = Math.sin(radlat)
|
||||
var magic = sin(radlat)
|
||||
magic = 1.0 - ee * magic * magic
|
||||
val sqrtmagic = Math.sqrt(magic)
|
||||
val sqrtmagic = sqrt(magic)
|
||||
dlat = dlat * 180.0 / (a * (1 - ee) / (magic * sqrtmagic) * PI)
|
||||
dlng = dlng * 180.0 / (a / sqrtmagic * Math.cos(radlat) * PI)
|
||||
dlng = dlng * 180.0 / (a / sqrtmagic * cos(radlat) * PI)
|
||||
val mglat = lat + dlat
|
||||
val mglng = lng + dlng
|
||||
doubleArrayOf(dealRound(lng * 2.0 - mglng), dealRound(lat * 2.0 - mglat))
|
||||
@@ -181,10 +182,10 @@ object TransformUtils {
|
||||
// System.out.println(outOfChina(40.057719, 119.942505))
|
||||
// var lonlatPoint = LonLatPoint(116.411196,39.968048)
|
||||
// System.out.println("$lonlatPoint")
|
||||
var doubleArray = transformGcj02toWgs84(40.01958683440374,116.32221523390801)
|
||||
System.out.println("transformGcj02toWgs84--${doubleArray[0]},${doubleArray[1]}")
|
||||
var doubleArray1 = transformWgs84ToGcj02(doubleArray[1], doubleArray[0])
|
||||
System.out.println("transformWgs84ToGcj02--${doubleArray1[0]},${doubleArray1[1]}")
|
||||
val doubleArray = transformGcj02toWgs84(40.01958683440374,116.32221523390801)
|
||||
println("transformGcj02toWgs84--${doubleArray[0]},${doubleArray[1]}")
|
||||
val doubleArray1 = transformWgs84ToGcj02(doubleArray[1], doubleArray[0])
|
||||
println("transformWgs84ToGcj02--${doubleArray1[0]},${doubleArray1[1]}")
|
||||
// var doubleArray2 = transformWgsToGcj(doubleArray[1], doubleArray[0])
|
||||
// System.out.println("transformWgs84ToGcj02--${dealRound(doubleArray1!![0])},${doubleArray1!![1]}")
|
||||
// System.out.println("transformWgs84ToGcj02--${dealRound(doubleArray2!![0])},${doubleArray2!![1]}")
|
||||
|
||||
@@ -24,7 +24,7 @@ object ZipUtils {
|
||||
try {
|
||||
zos = ZipOutputStream(out)
|
||||
val sourceFile = File(srcDir)
|
||||
compress(sourceFile, zos, sourceFile.getName(), KeepDirStructure)
|
||||
compress(sourceFile, zos, sourceFile.name, KeepDirStructure)
|
||||
val end = System.currentTimeMillis()
|
||||
println("压缩完成,耗时:" + (end - start) + " ms")
|
||||
} catch (e: Exception) {
|
||||
@@ -53,7 +53,7 @@ object ZipUtils {
|
||||
zos = ZipOutputStream(out)
|
||||
for (srcFile in srcFiles) {
|
||||
val buf = ByteArray(BUFFER_SIZE)
|
||||
val zipEntry = ZipEntry(srcFile.getName())
|
||||
val zipEntry = ZipEntry(srcFile.name)
|
||||
val fileTime = FileTime.fromMillis(0)
|
||||
zipEntry.lastAccessTime = fileTime
|
||||
zipEntry.lastModifiedTime = fileTime
|
||||
@@ -175,11 +175,10 @@ object ZipUtils {
|
||||
return null
|
||||
}
|
||||
val bigInteger = BigInteger(1, digest.digest())
|
||||
var md5Value = bigInteger.toString(16)
|
||||
// if(md5Value.length == 31){
|
||||
// if(md5Value.length == 31){
|
||||
// md5Value = "0${md5Value}"
|
||||
// }
|
||||
return md5Value
|
||||
return bigInteger.toString(16)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ object DeadZoneHelper {
|
||||
Log.i(TAG, "dealParam: ${System.currentTimeMillis()},$time,$lon,$lat,$angle,${MapTools.convertAngle((450-angle)%360, lon, lat)}")
|
||||
}
|
||||
angle = MapTools.convertAngle((450-angle)%360, lon, lat)
|
||||
var circleAngleInterval = lines[dataLineIndex++].trim().toFloat()
|
||||
val circleAngleInterval = lines[dataLineIndex++].trim().toFloat()
|
||||
|
||||
var count = (360 / circleAngleInterval).toInt()
|
||||
val count = (360 / circleAngleInterval).toInt()
|
||||
var countIndex = 1
|
||||
val list = ArrayList<LonLatPoint>()
|
||||
while (countIndex <= count && dataLineIndex + countIndex < lines.size) {
|
||||
|
||||
@@ -3,16 +3,7 @@ package com.zhidaoauto.map.sdk.open.camera
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
import com.zhidaoauto.map.sdk.inner.utils.TransformUtils
|
||||
|
||||
class LatLngBounds {
|
||||
|
||||
var southwest: LonLatPoint? = null
|
||||
var northeast: LonLatPoint? = null
|
||||
|
||||
constructor(southwest: LonLatPoint?, northeast: LonLatPoint?) {
|
||||
this.southwest = southwest
|
||||
this.northeast = northeast
|
||||
}
|
||||
|
||||
class LatLngBounds(var southwest: LonLatPoint?, var northeast: LonLatPoint?) {
|
||||
|
||||
companion object {
|
||||
fun c(var0: Double, var2: Double): Double {
|
||||
@@ -33,16 +24,16 @@ class LatLngBounds {
|
||||
return if (lonLatPoint == null) {
|
||||
this
|
||||
} else {
|
||||
mSouth = Math.min(mSouth, lonLatPoint.latitude)
|
||||
mNorth = Math.max(mNorth, lonLatPoint.latitude)
|
||||
mSouth = mSouth.coerceAtMost(lonLatPoint.latitude)
|
||||
mNorth = mNorth.coerceAtLeast(lonLatPoint.latitude)
|
||||
val var2: Double = lonLatPoint.longitude
|
||||
if (java.lang.Double.isNaN(mWest)) {
|
||||
mWest = var2
|
||||
} else {
|
||||
if (if (mWest <= mEast) mWest <= var2 && var2 <= mEast else mWest <= var2 || var2 <= mEast) {
|
||||
if (if (mWest <= mEast) var2 in mWest..mEast else mWest <= var2 || var2 <= mEast) {
|
||||
return this
|
||||
}
|
||||
if (LatLngBounds.c(mWest, var2) < LatLngBounds.d(mEast, var2)) {
|
||||
if (c(mWest, var2) < d(mEast, var2)) {
|
||||
mWest = var2
|
||||
return this
|
||||
}
|
||||
|
||||
@@ -3,11 +3,7 @@ package com.zhidaoauto.map.sdk.open.circle
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController
|
||||
|
||||
|
||||
class CircleController {
|
||||
private var id: String? = null
|
||||
constructor(id: String?) {
|
||||
this.id = id
|
||||
}
|
||||
class CircleController(private var id: String?) {
|
||||
|
||||
fun getId(): String? {
|
||||
return id
|
||||
|
||||
@@ -141,15 +141,15 @@ object MapDataApi {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "queryop getRouteAngle")
|
||||
}
|
||||
val startLonLat =
|
||||
val start =
|
||||
CommonProxy.getInstance().getLonLatProxy().switchLonLat(startLonLat)
|
||||
val endLonLat =
|
||||
val end =
|
||||
CommonProxy.getInstance().getLonLatProxy().switchLonLat(endLonLat)
|
||||
return RoadHelper.getInstance()?.getRouteAngle(
|
||||
startLonLat.lon.toFloat(),
|
||||
startLonLat.lat.toFloat(),
|
||||
endLonLat.lon.toFloat(),
|
||||
endLonLat.lat.toFloat()
|
||||
start.lon.toFloat(),
|
||||
start.lat.toFloat(),
|
||||
end.lon.toFloat(),
|
||||
end.lat.toFloat()
|
||||
)?:0f
|
||||
}
|
||||
|
||||
@@ -270,15 +270,15 @@ object MapDataApi {
|
||||
* 是否合法的经纬度
|
||||
*/
|
||||
fun isRightLonLat(lon:Double,lat:Double):Boolean{
|
||||
var rightLon = false;
|
||||
var rightLat = false;
|
||||
var rightLon = false
|
||||
var rightLat = false
|
||||
if (lon > -180.0 && lon < 180.0) {
|
||||
rightLon = true;
|
||||
rightLon = true
|
||||
}
|
||||
if (lat > -90.0 && lat < 90.0) {
|
||||
rightLat = true;
|
||||
rightLat = true
|
||||
}
|
||||
return rightLon && rightLat;
|
||||
return rightLon && rightLat
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -6,20 +6,17 @@ import com.alibaba.fastjson.JSONException
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController
|
||||
|
||||
class DeadZone {
|
||||
class DeadZone(deadZoneOptions: DeadZoneOptions, mapController: IMapController?) {
|
||||
private val TAG = "DeadZone"
|
||||
|
||||
private var id: String? = null
|
||||
private var mDeadZoneOptions: DeadZoneOptions? = null
|
||||
private var mMapController:IMapController? = null
|
||||
private var mDeadZoneOptions: DeadZoneOptions? = deadZoneOptions
|
||||
private var mMapController:IMapController? = mapController
|
||||
|
||||
constructor(deadZoneOptions: DeadZoneOptions,mapController: IMapController?){
|
||||
mDeadZoneOptions = deadZoneOptions
|
||||
mMapController = mapController
|
||||
init {
|
||||
id = deadZoneOptions.getId()
|
||||
}
|
||||
|
||||
|
||||
fun remove() {
|
||||
// 移除单个盲区
|
||||
id?.let {
|
||||
|
||||
@@ -27,8 +27,6 @@ class DeadZoneOptions {
|
||||
this.id = UUID.randomUUID().toString()
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun setPosition(list:List<LonLatPoint>?):DeadZoneOptions{
|
||||
list?.let {
|
||||
try {
|
||||
@@ -39,9 +37,9 @@ class DeadZoneOptions {
|
||||
continue
|
||||
}
|
||||
if (!isGps) {
|
||||
lonLat = getInstance().getLonLatProxy().switchLonLat(list.get(i))
|
||||
lonLat = getInstance().getLonLatProxy().switchLonLat(list[i])
|
||||
} else {
|
||||
lonLat = LonLat(list.get(i).longitude, list.get(i).latitude)
|
||||
lonLat = LonLat(list[i].longitude, list[i].latitude)
|
||||
}
|
||||
lonLats.add(lonLat)
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ abstract class BaseDialog {
|
||||
}
|
||||
fun showNextModalDialog() {
|
||||
Log.i("###", "showNextModalDialog: " + dialogList.size)
|
||||
dialogList.get(0).showDialog()
|
||||
dialogList[0].showDialog()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import android.view.View
|
||||
import android.view.Window
|
||||
import com.zhidaoauto.map.sdk.R
|
||||
|
||||
class CustomDialog:BaseDialog {
|
||||
class CustomDialog() : BaseDialog() {
|
||||
|
||||
private var isCanCancel = false
|
||||
private var customDialog: CustomDialog? = null
|
||||
@@ -21,11 +21,8 @@ class CustomDialog:BaseDialog {
|
||||
private var mDialogHelper:DialogHelper? = null
|
||||
|
||||
|
||||
constructor(){
|
||||
}
|
||||
|
||||
companion object{
|
||||
protected var dialogList: ArrayList<CustomDialog> = ArrayList<CustomDialog>()
|
||||
protected var dialogList: ArrayList<CustomDialog> = ArrayList()
|
||||
|
||||
fun show(context: Context?, layoutResId: Int): CustomDialog {
|
||||
val customView = LayoutInflater.from(context).inflate(layoutResId, null)
|
||||
@@ -93,7 +90,7 @@ class CustomDialog:BaseDialog {
|
||||
builder.setCancelable(isCanCancel)
|
||||
alertDialog = builder.create()
|
||||
alertDialog?.setView(rootView)
|
||||
val window: Window? = alertDialog?.getWindow()
|
||||
val window: Window? = alertDialog?.window
|
||||
window?.setGravity(mGravity)
|
||||
getDialogLifeCycleListener().onCreate(alertDialog)
|
||||
if (isCanCancel){
|
||||
|
||||
@@ -112,13 +112,11 @@ class InputDialog private constructor() : BaseDialog() {
|
||||
log("启动输入对话框 -> $message")
|
||||
if (style == -1) style = DialogSettings.style
|
||||
dialogList.remove(inputDialog!!)
|
||||
val builder: AlertDialog.Builder
|
||||
builder = AlertDialog.Builder(context!!)
|
||||
val builder: AlertDialog.Builder = AlertDialog.Builder(context!!)
|
||||
alertDialog = builder.create()
|
||||
alertDialog!!.setView(EditText(context))
|
||||
getDialogLifeCycleListener().onCreate(alertDialog)
|
||||
if (isCanCancel) alertDialog!!.setCanceledOnTouchOutside(true)
|
||||
val rootView: View
|
||||
val fragmentManager = (context as Activity?)!!.fragmentManager
|
||||
mDialogHelper = DialogHelper().setAlertDialog(alertDialog, object : OnDismissListener {
|
||||
override fun onDismiss() {
|
||||
@@ -130,84 +128,84 @@ class InputDialog private constructor() : BaseDialog() {
|
||||
getDialogLifeCycleListener().onDismiss()
|
||||
onDismissListener!!.onDismiss()
|
||||
isDialogShown = false
|
||||
if (!dialogList.isEmpty()) {
|
||||
if (dialogList.isNotEmpty()) {
|
||||
showNextModalDialog()
|
||||
}
|
||||
context = null
|
||||
}
|
||||
})
|
||||
val window = alertDialog?.getWindow();
|
||||
rootView = LayoutInflater.from(context).inflate(R.layout.dialog_select, null);
|
||||
alertDialog?.setView(rootView);
|
||||
mDialogHelper?.show(fragmentManager, "kongzueDialog");
|
||||
val window = alertDialog?.window
|
||||
val rootView: View = LayoutInflater.from(context).inflate(R.layout.dialog_select, null)
|
||||
alertDialog?.setView(rootView)
|
||||
mDialogHelper?.show(fragmentManager, "kongzueDialog")
|
||||
|
||||
bkg = rootView?.findViewById(R.id.bkg) as LinearLayout
|
||||
txtDialogTitle = rootView.findViewById(R.id.txt_dialog_title);
|
||||
txtDialogTip = rootView.findViewById(R.id.txt_dialog_tip);
|
||||
txtInput = rootView.findViewById(R.id.txt_input);
|
||||
btnSelectNegative = rootView.findViewById(R.id.btn_selectNegative);
|
||||
btnSelectPositive = rootView.findViewById(R.id.btn_selectPositive);
|
||||
customView = rootView.findViewById(R.id.box_custom);
|
||||
bkg = rootView.findViewById(R.id.bkg) as LinearLayout
|
||||
txtDialogTitle = rootView.findViewById(R.id.txt_dialog_title)
|
||||
txtDialogTip = rootView.findViewById(R.id.txt_dialog_tip)
|
||||
txtInput = rootView.findViewById(R.id.txt_input)
|
||||
btnSelectNegative = rootView.findViewById(R.id.btn_selectNegative)
|
||||
btnSelectPositive = rootView.findViewById(R.id.btn_selectPositive)
|
||||
customView = rootView.findViewById(R.id.box_custom)
|
||||
|
||||
if (inputInfo != null) {
|
||||
|
||||
txtInput?.setFilters(arrayOf<InputFilter>(LengthFilter(inputInfo!!.maX_LENGTH)))
|
||||
txtInput?.setInputType(inputInfo!!.getInputType());
|
||||
txtInput?.filters = arrayOf<InputFilter>(LengthFilter(inputInfo!!.maX_LENGTH))
|
||||
txtInput?.inputType = inputInfo!!.inputType
|
||||
}
|
||||
|
||||
if (isNull(title)) {
|
||||
txtDialogTitle?.setVisibility(View.GONE);
|
||||
txtDialogTitle?.visibility = View.GONE
|
||||
} else {
|
||||
txtDialogTitle?.setVisibility(View.VISIBLE);
|
||||
txtDialogTitle?.setText(title);
|
||||
txtDialogTitle?.visibility = View.VISIBLE
|
||||
txtDialogTitle?.text = title
|
||||
}
|
||||
if (isNull(message)) {
|
||||
txtDialogTip?.setVisibility(View.GONE);
|
||||
txtDialogTip?.visibility = View.GONE
|
||||
} else {
|
||||
txtDialogTip?.setVisibility(View.VISIBLE);
|
||||
txtDialogTip?.setText(message);
|
||||
txtDialogTip?.visibility = View.VISIBLE
|
||||
txtDialogTip?.text = message
|
||||
}
|
||||
|
||||
|
||||
txtInput?.setVisibility(View.VISIBLE);
|
||||
txtInput?.setText(defaultInputText);
|
||||
txtInput?.setHint(defaultInputHint);
|
||||
txtInput?.visibility = View.VISIBLE
|
||||
txtInput?.setText(defaultInputText)
|
||||
txtInput?.hint = defaultInputHint
|
||||
|
||||
btnSelectNegative?.setVisibility(View.VISIBLE);
|
||||
btnSelectPositive?.setText(okButtonCaption);
|
||||
btnSelectPositive?.setOnClickListener({
|
||||
btnSelectNegative?.visibility = View.VISIBLE
|
||||
btnSelectPositive?.text = okButtonCaption
|
||||
btnSelectPositive?.setOnClickListener {
|
||||
fun onClick(v: View) {
|
||||
setIMMStatus(false, txtInput);
|
||||
onOkButtonClickListener?.onClick(alertDialog, txtInput?.getText().toString());
|
||||
onCancelButtonClickListener = null;
|
||||
setIMMStatus(false, txtInput)
|
||||
onOkButtonClickListener?.onClick(alertDialog, txtInput?.text.toString())
|
||||
onCancelButtonClickListener = null
|
||||
}
|
||||
})
|
||||
btnSelectNegative?.setText(cancelButtonCaption);
|
||||
btnSelectNegative?.setOnClickListener({
|
||||
}
|
||||
btnSelectNegative?.text = cancelButtonCaption
|
||||
btnSelectNegative?.setOnClickListener {
|
||||
fun onClick(v: View) {
|
||||
mDialogHelper?.dismissAllowingStateLoss();
|
||||
onCancelButtonClickListener?.onClick(alertDialog, DialogInterface.BUTTON_NEGATIVE);
|
||||
onCancelButtonClickListener = null;
|
||||
mDialogHelper?.dismissAllowingStateLoss()
|
||||
onCancelButtonClickListener?.onClick(alertDialog, DialogInterface.BUTTON_NEGATIVE)
|
||||
onCancelButtonClickListener = null
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// if (dialog_theme == THEME_DARK) {
|
||||
// bkg.setBackgroundResource(R.color.dlg_bkg_dark);
|
||||
// btnSelectNegative.setBackgroundResource(R.drawable.button_dialog_kongzue_gray_dark);
|
||||
// btnSelectPositive.setBackgroundResource(R.drawable.button_dialog_kongzue_blue_dark);
|
||||
// btnSelectNegative.setTextColor(Color.rgb(255, 255, 255));
|
||||
// btnSelectPositive.setTextColor(Color.rgb(255, 255, 255));
|
||||
// txtInput.setTextColor(Color.rgb(255, 255, 255));
|
||||
// txtInput.setBackgroundResource(R.drawable.editbox_bkg_dark);
|
||||
// bkg.setBackgroundResource(R.color.dlg_bkg_dark)
|
||||
// btnSelectNegative.setBackgroundResource(R.drawable.button_dialog_kongzue_gray_dark)
|
||||
// btnSelectPositive.setBackgroundResource(R.drawable.button_dialog_kongzue_blue_dark)
|
||||
// btnSelectNegative.setTextColor(Color.rgb(255, 255, 255))
|
||||
// btnSelectPositive.setTextColor(Color.rgb(255, 255, 255))
|
||||
// txtInput.setTextColor(Color.rgb(255, 255, 255))
|
||||
// txtInput.setBackgroundResource(R.drawable.editbox_bkg_dark)
|
||||
// }
|
||||
|
||||
useTextInfo(txtDialogTitle, customTitleTextInfo);
|
||||
useTextInfo(txtDialogTip, customContentTextInfo);
|
||||
useTextInfo(btnSelectNegative, customButtonTextInfo);
|
||||
useTextInfo(btnSelectPositive, customOkButtonTextInfo);
|
||||
useTextInfo(txtDialogTitle, customTitleTextInfo)
|
||||
useTextInfo(txtDialogTip, customContentTextInfo)
|
||||
useTextInfo(btnSelectNegative, customButtonTextInfo)
|
||||
useTextInfo(btnSelectPositive, customOkButtonTextInfo)
|
||||
|
||||
// if (dialog_background_color != -1) {
|
||||
// bkg.setBackgroundResource(dialog_background_color);
|
||||
// bkg.setBackgroundResource(dialog_background_color)
|
||||
// }
|
||||
|
||||
mDialogHelper?.show(fragmentManager!!, "customDialog")
|
||||
@@ -272,9 +270,7 @@ class InputDialog private constructor() : BaseDialog() {
|
||||
}
|
||||
|
||||
private fun isNull(s: String?): Boolean {
|
||||
return if (s == null || s.trim { it <= ' ' }.isEmpty() || s == "null") {
|
||||
true
|
||||
} else false
|
||||
return s == null || s.trim { it <= ' ' }.isEmpty() || s == "null"
|
||||
}
|
||||
|
||||
private fun setIMMStatus(show: Boolean, editText: EditText?) {
|
||||
|
||||
@@ -411,14 +411,7 @@ public class ProgressView extends View {
|
||||
super.scheduleSelf(what, when);
|
||||
}
|
||||
|
||||
private final Runnable mUpdater = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
update();
|
||||
}
|
||||
|
||||
};
|
||||
private final Runnable mUpdater = this::update;
|
||||
|
||||
private void update() {
|
||||
switch (mProgressMode) {
|
||||
|
||||
@@ -82,35 +82,34 @@ class TipDialog private constructor() : BaseDialog() {
|
||||
image = rootView.findViewById(R.id.image)
|
||||
txtInfo = rootView.findViewById(R.id.txt_info)
|
||||
txtInfo?.setTextColor(font_color)
|
||||
if (true) {
|
||||
blur = BlurView(context, null)
|
||||
boxBkg?.post(Runnable {
|
||||
val params = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
blur?.layoutParams = params
|
||||
blur?.setOverlayColor(blur_front_color)
|
||||
boxBkg?.addView(blur, 0, params)
|
||||
})
|
||||
boxBkg?.getViewTreeObserver()?.addOnGlobalLayoutListener {
|
||||
val boxBkgLayoutParams = boxBkg?.getLayoutParams()
|
||||
boxBkgLayoutParams?.width = boxInfo?.getWidth()
|
||||
boxBkgLayoutParams?.height = boxInfo?.getHeight()
|
||||
boxBkg?.setLayoutParams(boxBkgLayoutParams)
|
||||
}
|
||||
} else {
|
||||
boxInfo?.setBackgroundResource(bkgResId)
|
||||
blur = BlurView(context, null)
|
||||
boxBkg?.post {
|
||||
val params = RelativeLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
blur?.layoutParams = params
|
||||
blur?.setOverlayColor(blur_front_color)
|
||||
boxBkg?.addView(blur, 0, params)
|
||||
}
|
||||
boxBkg?.viewTreeObserver?.addOnGlobalLayoutListener {
|
||||
val boxBkgLayoutParams = boxBkg?.layoutParams
|
||||
boxBkgLayoutParams?.width = boxInfo?.width
|
||||
boxBkgLayoutParams?.height = boxInfo?.height
|
||||
boxBkg?.layoutParams = boxBkgLayoutParams
|
||||
}
|
||||
when (type) {
|
||||
TYPE_WARNING -> if (tip_theme === THEME_LIGHT) {
|
||||
TYPE_WARNING -> if (tip_theme == THEME_LIGHT) {
|
||||
image?.setImageResource(R.mipmap.img_warning_dark)
|
||||
} else {
|
||||
image?.setImageResource(R.mipmap.img_warning)
|
||||
}
|
||||
TYPE_ERROR -> if (tip_theme === THEME_LIGHT) {
|
||||
TYPE_ERROR -> if (tip_theme == THEME_LIGHT) {
|
||||
image?.setImageResource(R.mipmap.img_error_dark)
|
||||
} else {
|
||||
image?.setImageResource(R.mipmap.img_error)
|
||||
}
|
||||
TYPE_FINISH -> if (tip_theme === THEME_LIGHT) {
|
||||
TYPE_FINISH -> if (tip_theme == THEME_LIGHT) {
|
||||
image?.setImageResource(R.mipmap.img_finish_dark)
|
||||
} else {
|
||||
image?.setImageResource(R.mipmap.img_finish)
|
||||
@@ -118,11 +117,11 @@ class TipDialog private constructor() : BaseDialog() {
|
||||
TYPE_CUSTOM_BITMAP -> image?.setImageBitmap(customBitmap)
|
||||
TYPE_CUSTOM_DRAWABLE -> image?.setImageDrawable(customDrawable)
|
||||
}
|
||||
if (!tip!!.isEmpty()) {
|
||||
boxInfo?.setVisibility(View.VISIBLE)
|
||||
txtInfo?.setText(tip)
|
||||
if (tip!!.isNotEmpty()) {
|
||||
boxInfo?.visibility = View.VISIBLE
|
||||
txtInfo?.text = tip
|
||||
} else {
|
||||
boxInfo?.setVisibility(View.GONE)
|
||||
boxInfo?.visibility = View.GONE
|
||||
}
|
||||
if (customTextInfo!!.fontSize > 0) {
|
||||
txtInfo?.setTextSize(TypedValue.COMPLEX_UNIT_DIP, customTextInfo!!.fontSize.toFloat())
|
||||
@@ -131,10 +130,10 @@ class TipDialog private constructor() : BaseDialog() {
|
||||
txtInfo?.setTextColor(customTextInfo!!.fontColor)
|
||||
}
|
||||
if (customTextInfo!!.gravity != -1) {
|
||||
txtInfo?.setGravity(customTextInfo!!.gravity)
|
||||
txtInfo?.gravity = customTextInfo!!.gravity
|
||||
}
|
||||
val font = Typeface.create(Typeface.SANS_SERIF, if (customTextInfo!!.isBold) Typeface.BOLD else Typeface.NORMAL)
|
||||
txtInfo?.setTypeface(font)
|
||||
txtInfo?.typeface = font
|
||||
getDialogLifeCycleListener().onShow(alertDialog)
|
||||
var time = 1500
|
||||
when (howLong) {
|
||||
|
||||
@@ -46,7 +46,7 @@ class WaitDialog private constructor() : BaseDialog() {
|
||||
log("显示等待对话框 -> $tip")
|
||||
val builder: AlertDialog.Builder
|
||||
val bkgResId: Int
|
||||
when (DialogSettings.tip_theme) {
|
||||
when (tip_theme) {
|
||||
THEME_LIGHT -> {
|
||||
builder = AlertDialog.Builder(context, R.style.lightMode)
|
||||
bkgResId = R.drawable.rect_light
|
||||
@@ -89,41 +89,44 @@ class WaitDialog private constructor() : BaseDialog() {
|
||||
txtInfo = rootView.findViewById(R.id.txt_info)
|
||||
txtInfo?.setTextColor(font_color)
|
||||
if (customView != null) {
|
||||
progress?.setVisibility(View.GONE)
|
||||
progress?.visibility = View.GONE
|
||||
boxProgress?.removeAllViews()
|
||||
boxProgress?.addView(customView)
|
||||
}
|
||||
if (tip_theme === THEME_LIGHT) {
|
||||
if (tip_theme == THEME_LIGHT) {
|
||||
progress?.setStrokeColors(intArrayOf(Color.rgb(0, 0, 0)))
|
||||
} else {
|
||||
progress?.setStrokeColors(intArrayOf(Color.rgb(255, 255, 255)))
|
||||
}
|
||||
if (use_blur) {
|
||||
blur = BlurView(context, null)
|
||||
boxBkg?.post(Runnable {
|
||||
val params = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
boxBkg?.post {
|
||||
val params = RelativeLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
blur!!.layoutParams = params
|
||||
blur!!.setOverlayColor(blur_front_color)
|
||||
boxBkg?.addView(blur, 0, params)
|
||||
})
|
||||
boxBkg?.getViewTreeObserver()?.addOnGlobalLayoutListener {
|
||||
val boxBkgLayoutParams = boxBkg?.getLayoutParams()
|
||||
boxBkgLayoutParams?.width = boxInfo?.getWidth()
|
||||
boxBkgLayoutParams?.height = boxInfo?.getHeight()
|
||||
boxBkg?.setLayoutParams(boxBkgLayoutParams)
|
||||
}
|
||||
boxBkg?.viewTreeObserver?.addOnGlobalLayoutListener {
|
||||
val boxBkgLayoutParams = boxBkg?.layoutParams
|
||||
boxBkgLayoutParams?.width = boxInfo?.width
|
||||
boxBkgLayoutParams?.height = boxInfo?.height
|
||||
boxBkg?.layoutParams = boxBkgLayoutParams
|
||||
}
|
||||
} else {
|
||||
boxBkg?.setBackgroundResource(bkgResId)
|
||||
}
|
||||
if (tip != null && !tip!!.isEmpty()) {
|
||||
txtInfo?.setVisibility(View.VISIBLE)
|
||||
txtInfo?.setText(tip)
|
||||
if (tip != null && tip!!.isNotEmpty()) {
|
||||
txtInfo?.visibility = View.VISIBLE
|
||||
txtInfo?.text = tip
|
||||
} else {
|
||||
txtInfo?.setVisibility(View.GONE)
|
||||
val lp = boxProgress?.getLayoutParams() as RelativeLayout.LayoutParams
|
||||
txtInfo?.visibility = View.GONE
|
||||
val lp = boxProgress?.layoutParams as RelativeLayout.LayoutParams
|
||||
lp.setMargins(0, 0, 0, 0)
|
||||
lp.addRule(RelativeLayout.CENTER_IN_PARENT)
|
||||
boxProgress?.setLayoutParams(lp)
|
||||
boxProgress?.layoutParams = lp
|
||||
}
|
||||
if (customTextInfo!!.fontSize > 0) {
|
||||
txtInfo?.setTextSize(TypedValue.COMPLEX_UNIT_DIP, customTextInfo!!.fontSize.toFloat())
|
||||
@@ -132,10 +135,10 @@ class WaitDialog private constructor() : BaseDialog() {
|
||||
txtInfo?.setTextColor(customTextInfo!!.fontColor)
|
||||
}
|
||||
if (customTextInfo!!.gravity != -1) {
|
||||
txtInfo?.setGravity(customTextInfo!!.gravity)
|
||||
txtInfo?.gravity = customTextInfo!!.gravity
|
||||
}
|
||||
val font = Typeface.create(Typeface.SANS_SERIF, if (customTextInfo!!.isBold) Typeface.BOLD else Typeface.NORMAL)
|
||||
txtInfo?.setTypeface(font)
|
||||
txtInfo?.typeface = font
|
||||
alertDialog?.setOnKeyListener(DialogInterface.OnKeyListener { dialog, keyCode, event ->
|
||||
if (event.action == KeyEvent.ACTION_UP) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
package com.zhidaoauto.map.sdk.open.exception
|
||||
|
||||
class RuntimeRemoteException : RuntimeException {
|
||||
constructor(exception: Throwable)
|
||||
class RuntimeRemoteException(exception: Throwable) : RuntimeException() {
|
||||
}
|
||||
@@ -27,19 +27,21 @@ import kotlinx.coroutines.launch
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
|
||||
class LocationClient : android.location.LocationListener {
|
||||
class LocationClient(context: Context, mapController: IMapController?) : android.location.LocationListener {
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
companion object{
|
||||
private const val TAG = "LocationClient"
|
||||
}
|
||||
|
||||
// 监听事件
|
||||
private val listeners = ArrayList<LocationListener>()
|
||||
private val gpsListeners = ArrayList<LocationListener>()
|
||||
var mapLocationListener : LonLatPointListener? = null
|
||||
var mContext: Context?
|
||||
var mMapController: IMapController?
|
||||
var mContext: Context? = context
|
||||
var mMapController: IMapController? = mapController
|
||||
var lastKnownMogoLocation: MogoLocation? = null
|
||||
|
||||
var sysTimeAndGpsTimeInterval:Long = 0L;
|
||||
var sysTimeAndGpsTimeInterval:Long = 0L
|
||||
//定位间隔
|
||||
var mIntervalMinLocation = 100L
|
||||
|
||||
@@ -56,14 +58,11 @@ class LocationClient : android.location.LocationListener {
|
||||
|
||||
var isRecorderTrack:Boolean = false
|
||||
|
||||
|
||||
//
|
||||
private var mLocationManager: LocationManager? = null
|
||||
|
||||
// 是否用外部数据
|
||||
private var mIsUseExtraGPSData: AtomicBoolean = AtomicBoolean(false)
|
||||
|
||||
|
||||
// 是否已开始系统定位
|
||||
private var isNativeStarted : AtomicBoolean = AtomicBoolean(false)
|
||||
|
||||
@@ -103,16 +102,8 @@ class LocationClient : android.location.LocationListener {
|
||||
private var historyLocationList: ArrayList<LonLatPoint>? = null
|
||||
private var historyAngleList: ArrayList<Float>? = null
|
||||
private var tempAngleList: ArrayList<Float>? = null
|
||||
|
||||
|
||||
private var mLocationJob:Job? = null
|
||||
|
||||
|
||||
constructor(context: Context,mapController: IMapController?) {
|
||||
mContext = context
|
||||
mMapController = mapController
|
||||
}
|
||||
|
||||
fun matchRoadEnable(enable: Boolean) {
|
||||
isMatchRoad = enable
|
||||
}
|
||||
@@ -205,7 +196,6 @@ class LocationClient : android.location.LocationListener {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -248,12 +238,9 @@ class LocationClient : android.location.LocationListener {
|
||||
if (!mIsUseExtraGPSData.get()) {
|
||||
return
|
||||
}
|
||||
var lon = location.longitude
|
||||
var lat = location.latitude
|
||||
|
||||
var localLocation = MogoLocation()
|
||||
localLocation.lon = lon
|
||||
localLocation.lat = lat
|
||||
val localLocation = MogoLocation()
|
||||
localLocation.lon = location.longitude
|
||||
localLocation.lat = location.latitude
|
||||
localLocation.provider = location.provider?:"gps"
|
||||
localLocation.speed = location.speed
|
||||
localLocation.altitude = location.altitude
|
||||
@@ -276,14 +263,14 @@ class LocationClient : android.location.LocationListener {
|
||||
|
||||
override fun onLocationChanged(alocation: Location) {
|
||||
if (mIsUseExtraGPSData.get()) {
|
||||
return;
|
||||
return
|
||||
}
|
||||
alocation?.let {
|
||||
alocation.let {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "locationop--onLocationChanged--:${it}")
|
||||
}
|
||||
sysTimeAndGpsTimeInterval = System.currentTimeMillis()-it.time
|
||||
var location = MogoLocation()
|
||||
val location = MogoLocation()
|
||||
location.lon = it.longitude
|
||||
location.lat = it.latitude
|
||||
location.provider = Constant.GPS
|
||||
@@ -346,7 +333,7 @@ class LocationClient : android.location.LocationListener {
|
||||
}
|
||||
|
||||
// Copy the location object to avoid modifying the original object.
|
||||
var location = mogoLocation.copy()
|
||||
val location = mogoLocation.copy()
|
||||
|
||||
// Convert the angle to the correct format.
|
||||
location.heading = MathUtils.convertAngle((location.heading % 360.0), location.lon, location.lat)
|
||||
@@ -395,10 +382,10 @@ class LocationClient : android.location.LocationListener {
|
||||
}
|
||||
|
||||
// Convert the GPS coordinates if the location is not obtained from GPS.
|
||||
var gpsLon: Double
|
||||
var gpsLat: Double
|
||||
var lon: Double
|
||||
var lat: Double
|
||||
val gpsLon: Double
|
||||
val gpsLat: Double
|
||||
val lon: Double
|
||||
val lat: Double
|
||||
if (isGps) {
|
||||
gpsLon = lonLatPoint.longitude
|
||||
gpsLat = lonLatPoint.latitude
|
||||
@@ -498,12 +485,12 @@ class LocationClient : android.location.LocationListener {
|
||||
gpsListeners.forEach { it.onLocationChanged(location) }
|
||||
// Notify the map location listener with the updated location data.
|
||||
if (isCallMap) {
|
||||
val lonLatPoint = LonLatPoint(location.lon, location.lat)
|
||||
lonLatPoint.angle = location.heading
|
||||
lonLatPoint.provider = location.provider
|
||||
lonLatPoint.duration = location.duration
|
||||
lonLatPoint.distance = location.distance
|
||||
mapLocationListener?.onLocationChanged(lonLatPoint)
|
||||
val point = LonLatPoint(location.lon, location.lat)
|
||||
point.angle = location.heading
|
||||
point.provider = location.provider
|
||||
point.duration = location.duration
|
||||
point.distance = location.distance
|
||||
mapLocationListener?.onLocationChanged(point)
|
||||
}
|
||||
// Update the last known location.
|
||||
lastKnownMogoLocation = location.copy()
|
||||
@@ -519,49 +506,60 @@ class LocationClient : android.location.LocationListener {
|
||||
*/
|
||||
fun updateLocation(temp: LonLatPoint) {
|
||||
// Check if the location is valid.
|
||||
if(!MapDataApi.isRightLonLat(temp.longitude,temp.latitude)){
|
||||
if (!MapDataApi.isRightLonLat(temp.longitude, temp.latitude)) {
|
||||
Log.e(TAG, "LocationClient-Location is error:${temp.longitude},${temp.latitude}")
|
||||
return;
|
||||
return
|
||||
}
|
||||
// Enable the use of extra GPS data.
|
||||
setIsUseExtraGPSData(true)
|
||||
var lonLatPoint = temp
|
||||
var duration = lonLatPoint.duration;
|
||||
if(duration == 0){
|
||||
var duration = temp.duration
|
||||
if (duration == 0) {
|
||||
// Set the duration as the animation duration.
|
||||
if (mLastLocationTime > 0L) {
|
||||
duration = (temp.satelliteTime - mLastLocationTime).toInt()
|
||||
}else{
|
||||
duration = 50;
|
||||
} else {
|
||||
duration = 50
|
||||
}
|
||||
mLastLocationTime = temp.satelliteTime
|
||||
}
|
||||
// Set the duration based on whether the RTK is enabled.
|
||||
if(isRTK && (duration>300 || duration == 0)){
|
||||
if (isRTK && (duration > 300 || duration == 0)) {
|
||||
duration = 50
|
||||
}else if(!isRTK && duration>1000){
|
||||
} else if (!isRTK && duration > 1000) {
|
||||
duration = 1000
|
||||
}
|
||||
lonLatPoint.duration = duration
|
||||
temp.duration = duration
|
||||
// Convert the angle if needed.
|
||||
if(lonLatPoint.isConvertAngle){
|
||||
lonLatPoint.angle = MathUtils.convertAngle(lonLatPoint.angle%360,lonLatPoint.longitude,lonLatPoint.latitude)
|
||||
if (temp.isConvertAngle) {
|
||||
temp.angle = MathUtils.convertAngle(
|
||||
temp.angle % 360,
|
||||
temp.longitude,
|
||||
temp.latitude
|
||||
)
|
||||
}
|
||||
// Calculate the distance between the current and last locations.
|
||||
lastLonLatPoint?.let{
|
||||
val distance = MathUtils.distance(it.longitude, it.latitude, lonLatPoint.longitude, lonLatPoint.latitude)
|
||||
lonLatPoint.distance = distance
|
||||
lastLonLatPoint?.let {
|
||||
val distance = MathUtils.distance(
|
||||
it.longitude,
|
||||
it.latitude,
|
||||
temp.longitude,
|
||||
temp.latitude
|
||||
)
|
||||
temp.distance = distance
|
||||
}
|
||||
// Set the distance to 1 if there is no last location.
|
||||
if(lastLonLatPoint == null){
|
||||
lonLatPoint.distance = 1.0
|
||||
if (lastLonLatPoint == null) {
|
||||
temp.distance = 1.0
|
||||
}
|
||||
// Update the last location and notify the listeners.
|
||||
lastLonLatPoint = lonLatPoint
|
||||
dealListener(lonLatPoint,true,true,true)
|
||||
lastLonLatPoint = temp
|
||||
dealListener(temp, true, true, true)
|
||||
// Output the location data if needed.
|
||||
if (isOutputLocation) {
|
||||
MapAutoApi.addLog("rtk","${System.currentTimeMillis()},${temp.longitude},${temp.latitude},${temp.altitude},${temp.angle},0,${lonLatPoint.speed},${lonLatPoint.distance},${lonLatPoint.satelliteTime}")
|
||||
MapAutoApi.addLog(
|
||||
"rtk",
|
||||
"${System.currentTimeMillis()},${temp.longitude},${temp.latitude},${temp.altitude},${temp.angle},0,${temp.speed},${temp.distance},${temp.satelliteTime}"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -610,10 +608,10 @@ class LocationClient : android.location.LocationListener {
|
||||
val distance = MathUtils.distance(it.lon, it.lat, rtkAutopilotLocationBean.lon, rtkAutopilotLocationBean.lat)
|
||||
|
||||
// Calculate the angle between the current and last locations.
|
||||
var outputCalAngle = GisGeomTool.GetLineAngle(it.lon, it.lat, rtkAutopilotLocationBean.lon, rtkAutopilotLocationBean.lat)
|
||||
val outputCalAngle = GisGeomTool.GetLineAngle(it.lon, it.lat, rtkAutopilotLocationBean.lon, rtkAutopilotLocationBean.lat)
|
||||
|
||||
// Add the location information to the log.
|
||||
MapAutoApi.addLog("rtk","${rtkAutopilotLocationBean?.satelliteTime},${rtkAutopilotLocationBean?.lon},${rtkAutopilotLocationBean?.lat},${rtkAutopilotLocationBean?.alt},${rtkAutopilotLocationBean?.heading},${outputCalAngle},${rtkAutopilotLocationBean?.gnss_speed},${distance},${System.currentTimeMillis()}")
|
||||
MapAutoApi.addLog("rtk","${rtkAutopilotLocationBean.satelliteTime},${rtkAutopilotLocationBean.lon},${rtkAutopilotLocationBean.lat},${rtkAutopilotLocationBean.alt},${rtkAutopilotLocationBean.heading},${outputCalAngle},${rtkAutopilotLocationBean.gnss_speed},${distance},${System.currentTimeMillis()}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,13 @@ import com.zhidaoauto.map.sdk.open.marker.Marker
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
class MyLocationStyle(private var mContext:Context?,private var mMarkerController: IMarkerController?,
|
||||
private var mMapController: IMapController?, private var mMapStyleParams: IMapStyleParams?) {
|
||||
val TAG = javaClass.simpleName
|
||||
class MyLocationStyle(
|
||||
private var mContext: Context?, private var mMarkerController: IMarkerController?,
|
||||
private var mMapController: IMapController?, private var mMapStyleParams: IMapStyleParams?
|
||||
) {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "MyLocationStyle"
|
||||
const val SELF_CAR_ID = "selfcar123"
|
||||
|
||||
const val LOCATION_TYPE_SHOW = 0 //只定位一次。
|
||||
@@ -31,15 +33,15 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
const val LOCATION_TYPE_FOLLOW = 2//连续定位、且将视角移动到地图中心点,定位蓝点跟随设备移动。(1秒1次定位) 默认执行此种模式
|
||||
const val LOCATION_TYPE_FOLLOW_NO_CENTER = 3 //连续定位、蓝点不会移动到地图中心点,并且蓝点会跟随设备移动。
|
||||
|
||||
const val ANIM_WAIT_FRAME_NIGHT = 35
|
||||
const val ANIM_WAIT_FRAME_NIGHT = 35
|
||||
const val ANIM_PERIOD_NIGHT = 60
|
||||
const val ANIM_WAIT_FRAME_DAY = 60
|
||||
const val ANIM_PERIOD_DAY = 45
|
||||
}
|
||||
|
||||
|
||||
private var mLonLat:LonLat = LonLat(Constants.BEIJING.lon,Constants.BEIJING.lat)
|
||||
private var mAngle:Float = 0.0f
|
||||
private var mLonLat: LonLat = LonLat(Constants.BEIJING.lon, Constants.BEIJING.lat)
|
||||
private var mAngle: Float = 0.0f
|
||||
private var locationCount = 0
|
||||
private var is3D: Boolean = false
|
||||
private var carId: Int = 0
|
||||
@@ -47,7 +49,7 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
private var mMarker: Marker? = null
|
||||
|
||||
private var lastExecuteTime = -1L
|
||||
private var lastLonLatPoint : LonLatPoint? = null
|
||||
private var lastLonLatPoint: LonLatPoint? = null
|
||||
|
||||
|
||||
private val zIndex = 1
|
||||
@@ -56,8 +58,10 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
|
||||
var myLocationIcon: Bitmap? = null
|
||||
var intervalTime: Long = 1000
|
||||
|
||||
// 2D资源
|
||||
var carResId: Int
|
||||
|
||||
// 3D夜间资源
|
||||
var car3DResId: Int
|
||||
|
||||
@@ -75,22 +79,21 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
carResId = mMapStyleParams?.getLocationIconRes() ?: R.mipmap.map_custom_self_car_night
|
||||
}
|
||||
|
||||
fun getSelfMarker():Marker?{
|
||||
fun getSelfMarker(): Marker? {
|
||||
return mMarker
|
||||
}
|
||||
|
||||
fun setDisplayAnimEnable(enable:Boolean){
|
||||
fun setDisplayAnimEnable(enable: Boolean) {
|
||||
mMapController?.getClerk()?.add("$enable,$guangquanResId")
|
||||
isDisplayAnim = enable
|
||||
mMarker?.setDisplayAnimEnable(isDisplayAnim)
|
||||
if(isDisplayAnim){
|
||||
if (isDisplayAnim) {
|
||||
mMarker?.getMarkeOptions()?.let {
|
||||
it.animMarkerRes(guangquanResId,mMapController)?.
|
||||
animWaitFrame(animWaitFrame)?.
|
||||
period(animPeriod)
|
||||
it.animMarkerRes(guangquanResId, mMapController).animWaitFrame(animWaitFrame)
|
||||
.period(animPeriod)
|
||||
mMarker?.setMarkerOptions(it)
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
//待增加删除之前动画模型的逻辑
|
||||
}
|
||||
}
|
||||
@@ -107,7 +110,7 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
// if(bitmap == null){
|
||||
// return this
|
||||
// }
|
||||
if(this.myLocationIcon != null){
|
||||
if (this.myLocationIcon != null) {
|
||||
this.myLocationIcon?.recycle()
|
||||
this.myLocationIcon = null
|
||||
}
|
||||
@@ -130,21 +133,22 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
mMarker?.setIcon(bitmap)
|
||||
return
|
||||
}
|
||||
if((mMapController?.isSurfaceCreated())?:false){
|
||||
if(executeFlag.get()){
|
||||
if ((mMapController?.isSurfaceCreated()) == true) {
|
||||
if (executeFlag.get()) {
|
||||
return
|
||||
}
|
||||
if (mMarker != null){
|
||||
if (mMarker != null) {
|
||||
return
|
||||
}
|
||||
executeFlag.set(true)
|
||||
var lon = mLonLat.lon
|
||||
var lat = mLonLat.lat
|
||||
var angle = mAngle
|
||||
val lon = mLonLat.lon
|
||||
val lat = mLonLat.lat
|
||||
val angle = mAngle
|
||||
try {
|
||||
val options = MarkerOptions(SELF_CAR_ID,mMapController).setGps(true)
|
||||
val options = MarkerOptions(SELF_CAR_ID, mMapController).setGps(true)
|
||||
.position(LonLatPoint(lon, lat))
|
||||
.markerIcon(bitmap,mMapController).zIndex(1).title("self").rotateAngle(angle.toFloat()).controlAngle(true).anchor(0.5f,0.5f)
|
||||
.markerIcon(bitmap, mMapController).zIndex(1).title("self")
|
||||
.rotateAngle(angle).controlAngle(true).anchor(0.5f, 0.5f)
|
||||
|
||||
mMarker = mMarkerController?.addSelfCar(options)
|
||||
if (CompileConfig.DEBUG) {
|
||||
@@ -152,7 +156,7 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
mMarker = null
|
||||
}finally {
|
||||
} finally {
|
||||
executeFlag.set(false)
|
||||
}
|
||||
}
|
||||
@@ -161,23 +165,28 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
|
||||
private fun draw3DCar(resId: Int) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop---selfop--draw3DCar:start:${resId},old:${mMarker?.getMarkeOptions()?.getMarkerIconName()}")
|
||||
Log.i(
|
||||
TAG,
|
||||
"markerop---selfop--draw3DCar:start:${resId},old:${
|
||||
mMarker?.getMarkeOptions()?.getMarkerIconName()
|
||||
}"
|
||||
)
|
||||
}
|
||||
if (mMarker != null) {
|
||||
|
||||
val markerOptions = mMarker?.getMarkeOptions()?.displayAnimEnable(isDisplayAnim)
|
||||
|
||||
if(isDisplayAnim){
|
||||
if (isDisplayAnim) {
|
||||
markerOptions?.animWaitFrame(animWaitFrame)?.period(animPeriod)
|
||||
?.animType(1)?.anchorType(1)
|
||||
markerOptions?.animMarkerRes(guangquanResId,mMapController)
|
||||
}else{
|
||||
markerOptions?.animMarkerRes(guangquanResId, mMapController)
|
||||
} else {
|
||||
//待增加删除之前动画模型的逻辑
|
||||
}
|
||||
|
||||
val markerIconName = mMarker?.getMarkeOptions()?.getMarkerIconName()
|
||||
if(TextUtils.isEmpty(markerIconName) || carId != resId){
|
||||
markerOptions?.marker3DIcon(resId,mMapController)
|
||||
if (TextUtils.isEmpty(markerIconName) || carId != resId) {
|
||||
markerOptions?.marker3DIcon(resId, mMapController)
|
||||
}
|
||||
markerOptions?.let {
|
||||
if (CompileConfig.DEBUG) {
|
||||
@@ -189,59 +198,60 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
|
||||
return
|
||||
}
|
||||
if((mMapController?.isSurfaceCreated())?:false){
|
||||
if ((mMapController?.isSurfaceCreated()) ?: false) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop---selfop--draw3DCar:start:mapView SurfaceCreated")
|
||||
}
|
||||
if(executeFlag.get()){
|
||||
if (executeFlag.get()) {
|
||||
return
|
||||
}
|
||||
if (mMarker != null){
|
||||
if (mMarker != null) {
|
||||
return
|
||||
}
|
||||
executeFlag.set(true)
|
||||
var lon = mLonLat.lon
|
||||
var lat = mLonLat.lat
|
||||
var angle = mAngle
|
||||
val lon = mLonLat.lon
|
||||
val lat = mLonLat.lat
|
||||
val angle = mAngle
|
||||
try {
|
||||
val options = MarkerOptions(SELF_CAR_ID,mMapController)
|
||||
val options = MarkerOptions(SELF_CAR_ID, mMapController)
|
||||
.setGps(true)
|
||||
.position(LonLatPoint(lon, lat))
|
||||
.marker3DIcon(resId,mMapController)
|
||||
.marker3DIcon(resId, mMapController)
|
||||
.displayAnimEnable(isDisplayAnim)
|
||||
.zIndex(zIndex)
|
||||
.title("self")
|
||||
.rotateAngle(angle.toFloat())
|
||||
.anchor(anchorU , anchorV)
|
||||
.rotateAngle(angle)
|
||||
.anchor(anchorU, anchorV)
|
||||
.controlAngle(true)
|
||||
.animType(1)
|
||||
.anchorType(1)
|
||||
.animWaitFrame(animWaitFrame)
|
||||
.period(animPeriod)
|
||||
if(isDisplayAnim){
|
||||
options?.animMarkerRes(guangquanResId,mMapController)
|
||||
if (isDisplayAnim) {
|
||||
options.animMarkerRes(guangquanResId, mMapController)
|
||||
}
|
||||
mMarker = mMarkerController?.addSelfCar(options)
|
||||
carId = resId
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "autoop--selfop--markerop--draw3DCar:${mMarker?.getId()},${resId},${options.getMarkerIconName()}")
|
||||
Log.i(
|
||||
TAG,
|
||||
"autoop--selfop--markerop--draw3DCar:${mMarker?.getId()},${resId},${options.getMarkerIconName()}"
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.e(TAG, "autoop--selfop--markerop--draw3DCar:${mMarker?.getId()}",e)
|
||||
Log.e(TAG, "autoop--selfop--markerop--draw3DCar:${mMarker?.getId()}", e)
|
||||
}
|
||||
mMarker = null
|
||||
}finally {
|
||||
} finally {
|
||||
executeFlag.set(false)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun setLonLat(lonLat: LonLat, angle: Double) {
|
||||
mMapController?.getClerk()?.add("${lonLat.lon},${lonLat.lat},${angle}")
|
||||
if(TransformUtils.outOfChina(lonLat.lat, lonLat.lon)){
|
||||
if (TransformUtils.outOfChina(lonLat.lat, lonLat.lon)) {
|
||||
return
|
||||
}
|
||||
if (CompileConfig.DEBUG) {
|
||||
@@ -250,19 +260,19 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
this.mLonLat = lonLat
|
||||
this.mAngle = angle.toFloat()
|
||||
if (mMarker == null) {
|
||||
if(is3D){
|
||||
if (is3D) {
|
||||
myLocationIcon(car3DResId, is3D)
|
||||
}else{
|
||||
} else {
|
||||
myLocationIcon(carResId, is3D)
|
||||
}
|
||||
}
|
||||
|
||||
mMarker?.setGps(true)
|
||||
if(lastLonLatPoint != null){
|
||||
executeTransAnim(lonLat,angle,System.currentTimeMillis() - lastExecuteTime)
|
||||
if (lastLonLatPoint != null) {
|
||||
executeTransAnim(lonLat, angle, System.currentTimeMillis() - lastExecuteTime)
|
||||
lastExecuteTime = System.currentTimeMillis()
|
||||
}else{
|
||||
val lonLatPoint = LonLatPoint(lonLat.lon, lonLat.lat,0.0,angle)
|
||||
} else {
|
||||
val lonLatPoint = LonLatPoint(lonLat.lon, lonLat.lat, 0.0, angle)
|
||||
mMarker?.setRotateAngle(angle.toFloat())
|
||||
mMarker?.setPosition(lonLatPoint)
|
||||
lastLonLatPoint = lonLatPoint
|
||||
@@ -271,7 +281,7 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
|
||||
}
|
||||
|
||||
fun setLonLat(lonLat: LonLat, angle: Float,duration: Long) {
|
||||
fun setLonLat(lonLat: LonLat, angle: Float, duration: Long) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "autoop--markerop---selfop-setLonLat-${lonLat},mMarker:${mMarker?.getId()}")
|
||||
}
|
||||
@@ -279,9 +289,9 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
this.mAngle = angle
|
||||
|
||||
if (mMarker == null) {
|
||||
if(is3D){
|
||||
if (is3D) {
|
||||
myLocationIcon(car3DResId, is3D)
|
||||
}else{
|
||||
} else {
|
||||
myLocationIcon(carResId, is3D)
|
||||
}
|
||||
}
|
||||
@@ -292,19 +302,25 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
}
|
||||
|
||||
|
||||
private fun executeTransAnim(lonLat: LonLat,angle:Double, duration: Long) {
|
||||
val lonLatPoint = LonLatPoint(lonLat.lon,lonLat.lat,0.0,angle)
|
||||
private fun executeTransAnim(lonLat: LonLat, angle: Double, duration: Long) {
|
||||
val lonLatPoint = LonLatPoint(lonLat.lon, lonLat.lat, 0.0, angle)
|
||||
var curDuration = duration
|
||||
if(curDuration > 300){
|
||||
if (curDuration > 300) {
|
||||
curDuration = 50
|
||||
}
|
||||
mMarker?.addDynamicAnchorPostion(lonLatPoint,System.currentTimeMillis(),curDuration.toInt(),1f,-1f)
|
||||
mMarker?.addDynamicAnchorPostion(
|
||||
lonLatPoint,
|
||||
System.currentTimeMillis(),
|
||||
curDuration.toInt(),
|
||||
1f,
|
||||
-1f
|
||||
)
|
||||
lastLonLatPoint = lonLatPoint
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun resetPosition(){
|
||||
fun resetPosition() {
|
||||
// mMapController?.getClerk()?.add()
|
||||
lastLonLatPoint = null
|
||||
}
|
||||
@@ -319,14 +335,17 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
}
|
||||
|
||||
|
||||
fun setScale(scale:Float){
|
||||
fun setScale(scale: Float) {
|
||||
mMarker?.setScale(scale)
|
||||
}
|
||||
|
||||
fun myLocationIcon(carResId: Int, is3D: Boolean): MyLocationStyle {
|
||||
mMapController?.getClerk()?.add("$is3D,$carResId")
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--selfop--myLocationIcon draw3DCar:${mMarker?.getId()},${carResId},${is3D}")
|
||||
Log.i(
|
||||
TAG,
|
||||
"markerop--selfop--myLocationIcon draw3DCar:${mMarker?.getId()},${carResId},${is3D}"
|
||||
)
|
||||
}
|
||||
if (carResId != 0) {
|
||||
|
||||
@@ -338,11 +357,11 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
this.carResId = carResId
|
||||
val bitmap = BitmapFactory.decodeResource(mContext?.resources, carResId)
|
||||
bitmap?.let {
|
||||
if(this.myLocationIcon != null){
|
||||
if (this.myLocationIcon != null) {
|
||||
this.myLocationIcon?.recycle()
|
||||
this.myLocationIcon = null
|
||||
}
|
||||
drawCar(it)
|
||||
drawCar(it)
|
||||
}
|
||||
carId = carResId
|
||||
}
|
||||
@@ -354,22 +373,25 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
fun myLocationIcon(carResId: Int): MyLocationStyle {
|
||||
mMapController?.getClerk()?.add("$carResId")
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--selfop--myLocationIcon drawCar:${mMarker},carResId:${carResId},res:${R.mipmap.map_custom_self_car_night}")
|
||||
Log.i(
|
||||
TAG,
|
||||
"markerop--selfop--myLocationIcon drawCar:${mMarker},carResId:${carResId},res:${R.mipmap.map_custom_self_car_night}"
|
||||
)
|
||||
}
|
||||
myLocationIcon(carResId, false)
|
||||
return this
|
||||
}
|
||||
|
||||
//设置光圈
|
||||
fun setAnimMarkerRes(resId: Int, waitFrame: Int, period: Int){
|
||||
if(animWaitFrame != waitFrame){
|
||||
fun setAnimMarkerRes(resId: Int, waitFrame: Int, period: Int) {
|
||||
if (animWaitFrame != waitFrame) {
|
||||
animWaitFrame = waitFrame
|
||||
}
|
||||
if(animPeriod != period){
|
||||
if (animPeriod != period) {
|
||||
animPeriod = period
|
||||
}
|
||||
|
||||
if(guangquanResId != resId){
|
||||
if (guangquanResId != resId) {
|
||||
// val markerOptions = mMarker?.getMarkeOptions()?.animMarkerRes(resId)
|
||||
// markerOptions?.let {
|
||||
// mMarker?.setMarkerOptions(it)
|
||||
@@ -388,7 +410,7 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
}
|
||||
|
||||
fun getMyLocationIcon(): Int {
|
||||
if(is3D){
|
||||
if (is3D) {
|
||||
return this.car3DResId
|
||||
}
|
||||
return this.carResId
|
||||
@@ -416,7 +438,7 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
Log.i(TAG, "selfop---markerop-carCursorRes")
|
||||
}
|
||||
if (carResId != 0) {
|
||||
myLocationIcon(carResId,false)
|
||||
myLocationIcon(carResId, false)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.zhidaoauto.map.sdk.open.location
|
||||
import com.alibaba.fastjson.annotation.JSONField
|
||||
import java.io.Serializable
|
||||
|
||||
open class RTKAutopilotLocationBean : Serializable {
|
||||
open class RTKAutopilotLocationBean() : Serializable {
|
||||
//经度
|
||||
@JSONField(name = "lon")
|
||||
var lon: Double = 0.0
|
||||
@@ -53,8 +53,6 @@ open class RTKAutopilotLocationBean : Serializable {
|
||||
|
||||
var duration:Int =0
|
||||
|
||||
constructor()
|
||||
|
||||
override fun toString(): String {
|
||||
return "RTKAutopilotLocationBean(lon=$lon, lat=$lat, alt=$alt, heading=$heading, gnss_speed=$gnss_speed, vehicle_speed=$vehicle_speed, acceleration=$acceleration, yaw_rate=$yaw_rate, turn_light=$turn_light, flash_light=$flash_light, brake_light=$brake_light, systemTime=$systemTime, satelliteTime=$satelliteTime, receiverDataTime=$receiverDataTime, adasSatelliteTime=$adasSatelliteTime)"
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class BitmapDescriptor : Parcelable, Cloneable {
|
||||
return ByteArray(0)
|
||||
}
|
||||
val bytes = it.byteCount
|
||||
var buf = ByteBuffer.allocateDirect(bytes)
|
||||
val buf = ByteBuffer.allocateDirect(bytes)
|
||||
it.copyPixelsToBuffer(buf)
|
||||
// it.recycle()
|
||||
return buf.array()
|
||||
|
||||
@@ -26,7 +26,7 @@ object BitmapDescriptorFactory {
|
||||
var totBuffer:ByteArray? = null
|
||||
var dis:DataInputStream? = null
|
||||
try {
|
||||
dis = DataInputStream(context.getResources()?.openRawResource(resId))
|
||||
dis = DataInputStream(context.resources?.openRawResource(resId))
|
||||
var curTotSize = 64 * 1024
|
||||
totBuffer = ByteArray(curTotSize)
|
||||
val buffer = ByteArray(1024)
|
||||
|
||||
@@ -9,15 +9,15 @@ object CarManager {
|
||||
var carSizeMap:HashMap<Int,DoubleArray> = HashMap()
|
||||
|
||||
init {
|
||||
carSizeMap.put(1, doubleArrayOf(112.0 / 2, 74.0 / 2))
|
||||
carSizeMap.put(2, doubleArrayOf(57.0 / 2, 539.0 / 2))
|
||||
carSizeMap.put(3, doubleArrayOf(429.0 / 2, 1001.0 / 2)) //429/1001是类型3对应渲染模型的x/y的长度
|
||||
carSizeMap.put(4, doubleArrayOf(247.0 / 2, 794.0 / 2))
|
||||
carSizeMap.put(6, doubleArrayOf(475.0 / 2, 1429.0 / 2))
|
||||
carSizeMap.put(101,doubleArrayOf(529.0 / 2, 1021.0 / 2))//东风
|
||||
carSizeMap.put(102,doubleArrayOf(435.0 / 2, 1041.0 / 2))//红旗
|
||||
carSizeMap.put(103,doubleArrayOf(581.0 / 2, 1449.0 / 2))//小巴
|
||||
carSizeMap.put(104,doubleArrayOf(845.0 / 2, 2501.0 / 2))//环卫
|
||||
carSizeMap[1] = doubleArrayOf(112.0 / 2, 74.0 / 2)
|
||||
carSizeMap[2] = doubleArrayOf(57.0 / 2, 539.0 / 2)
|
||||
carSizeMap[3] = doubleArrayOf(429.0 / 2, 1001.0 / 2) //429/1001是类型3对应渲染模型的x/y的长度
|
||||
carSizeMap[4] = doubleArrayOf(247.0 / 2, 794.0 / 2)
|
||||
carSizeMap[6] = doubleArrayOf(475.0 / 2, 1429.0 / 2)
|
||||
carSizeMap[101] = doubleArrayOf(529.0 / 2, 1021.0 / 2)//东风
|
||||
carSizeMap[102] = doubleArrayOf(435.0 / 2, 1041.0 / 2)//红旗
|
||||
carSizeMap[103] = doubleArrayOf(581.0 / 2, 1449.0 / 2)//小巴
|
||||
carSizeMap[104] = doubleArrayOf(845.0 / 2, 2501.0 / 2)//环卫
|
||||
|
||||
// carSizeMap.put(0, doubleArrayOf(1.4 / 2, 4.0 / 2))
|
||||
}
|
||||
@@ -29,7 +29,7 @@ object CarManager {
|
||||
* @param length 车辆长度
|
||||
*/
|
||||
fun updateCarSize(type:Int,width:Double,length:Double){
|
||||
carSizeMap.put(type, doubleArrayOf(width/2,length/2))
|
||||
carSizeMap[type] = doubleArrayOf(width/2,length/2)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,17 +43,14 @@ object CarManager {
|
||||
val map = HashMap<Long,ArrayList<CarInfo>>()
|
||||
val carInfoMap = HashMap<Long,CarInfo>()
|
||||
val size = list.size
|
||||
var buffer = StringBuffer()
|
||||
val buffer = StringBuffer()
|
||||
for(i in 0 until size) {
|
||||
val carInfoOne = list[i]
|
||||
if (!carSizeMap.containsKey(carInfoOne.type)) {
|
||||
continue
|
||||
}
|
||||
val carSizeOne = carSizeMap[carInfoOne.type]
|
||||
if (carSizeOne == null) {
|
||||
continue
|
||||
}
|
||||
carInfoMap.put(carInfoOne.id,carInfoOne)
|
||||
val carSizeOne = carSizeMap[carInfoOne.type] ?: continue
|
||||
carInfoMap[carInfoOne.id] = carInfoOne
|
||||
if(i > 0){
|
||||
buffer.append(",")
|
||||
}
|
||||
@@ -64,23 +61,23 @@ object CarManager {
|
||||
.append("${carSizeOne[0]}").append(",")
|
||||
.append("${carSizeOne[1]}")
|
||||
}
|
||||
if(buffer.isNullOrEmpty()){
|
||||
if(buffer.isEmpty()){
|
||||
return map
|
||||
}
|
||||
var coliRet = mapController?.isCollision(buffer.toString())
|
||||
val coliRet = mapController?.isCollision(buffer.toString())
|
||||
coliRet?.let{
|
||||
val li1 = coliRet?.split("|")
|
||||
val li1 = coliRet.split("|")
|
||||
for(i in 0 until li1.size){
|
||||
val li2 = li1[i].split(",")
|
||||
val first = li2[0]
|
||||
if(first.isNullOrEmpty())
|
||||
if(first.isEmpty())
|
||||
continue
|
||||
val collList = ArrayList<CarInfo>()
|
||||
for(j in 1 until li2.size){
|
||||
carInfoMap[li2[j].toLong()]?.let { collList.add(it) }
|
||||
}
|
||||
carInfoMap[first.toLong()]?.let { collList.add(it) }
|
||||
map.put(first.toLong(),collList)
|
||||
map[first.toLong()] = collList
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,32 +103,26 @@ object CarManager {
|
||||
if(!carSizeMap.containsKey(carInfoOne.type)){
|
||||
continue
|
||||
}
|
||||
val carSizeOne = carSizeMap[carInfoOne.type]
|
||||
if(carSizeOne == null){
|
||||
continue
|
||||
}
|
||||
val carSizeOne = carSizeMap[carInfoOne.type] ?: continue
|
||||
val collList = ArrayList<CarInfo>()
|
||||
val obbOne = OBB(carInfoOne.lon,carInfoOne.lat,selfLon,selfLat,carSizeOne[0],carSizeOne[1],carInfoOne.angle)
|
||||
System.out.println("$i:"+obbOne.toString())
|
||||
println("$i:"+obbOne.toString())
|
||||
for(j in i+1 until size){
|
||||
val carInfoTwo = list[j]
|
||||
if(!carSizeMap.containsKey(carInfoTwo.type)){
|
||||
continue
|
||||
}
|
||||
val carSizeTwo = carSizeMap[carInfoTwo.type]
|
||||
if(carSizeTwo == null){
|
||||
continue
|
||||
}
|
||||
val carSizeTwo = carSizeMap[carInfoTwo.type] ?: continue
|
||||
val obbTwo = OBB(carInfoTwo.lon,carInfoTwo.lat,selfLon,selfLat,carSizeTwo[0],carSizeTwo[1],carInfoTwo.angle)
|
||||
System.out.println("$j:"+obbTwo.toString())
|
||||
println("$j:"+obbTwo.toString())
|
||||
if(obbOne.isCollision(obbTwo)){
|
||||
collList.add(carInfoTwo)
|
||||
}
|
||||
|
||||
}
|
||||
if(!collList.isEmpty()){
|
||||
if(collList.isNotEmpty()){
|
||||
collList.add(carInfoOne)
|
||||
map.put(carInfoOne.id,collList)
|
||||
map[carInfoOne.id] = collList
|
||||
}
|
||||
}
|
||||
return map
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
|
||||
private var mInfoWindowAdapter: InfoWindowAdapter? = null
|
||||
private var markerAnimationListenerList: ArrayList<MarkerAnimationListener>? = null
|
||||
private var markerAnimationMap: HashMap<Int, Animation> = HashMap<Int, Animation>()
|
||||
private var markerAnimationMap: HashMap<Int, Animation> = HashMap()
|
||||
private var isExecuteAnimation: Boolean = false
|
||||
|
||||
private var historyLocationList: ArrayList<LonLatPoint>? = null
|
||||
@@ -59,11 +59,11 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
private var mHandler: Handler = object : Handler(Looper.getMainLooper()) {
|
||||
override fun handleMessage(msg: Message) {
|
||||
super.handleMessage(msg)
|
||||
var type = msg?.arg1
|
||||
var animation: Animation? = markerAnimationMap.get(type)
|
||||
val type = msg.arg1
|
||||
val animation: Animation? = markerAnimationMap[type]
|
||||
animation?.let {
|
||||
var listener: MarkerAnimationListener? = animation.getAnimationListener()
|
||||
when (msg?.arg2) {
|
||||
val listener: MarkerAnimationListener? = animation.getAnimationListener()
|
||||
when (msg.arg2) {
|
||||
START_ANIMATION -> {
|
||||
listener?.onAnimationStart(it)
|
||||
}
|
||||
@@ -76,8 +76,6 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,21 +105,21 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
}
|
||||
|
||||
fun setMarkerInfoName(markerInfoName: String) {
|
||||
markerOptions?.setMarkerInfoName(markerInfoName,mMapController,mMarkerCall)
|
||||
markerOptions.setMarkerInfoName(markerInfoName,mMapController,mMarkerCall)
|
||||
}
|
||||
|
||||
fun setClickable(clickable: Boolean) {
|
||||
markerOptions?.clickable(clickable)
|
||||
markerOptions.clickable(clickable)
|
||||
mMapController?.setSomeAnchorCanClickable(id, clickable)
|
||||
}
|
||||
|
||||
fun setScale(scale: Float) {
|
||||
markerOptions?.scale(scale)
|
||||
markerOptions.scale(scale)
|
||||
mMapController?.updateAnchorProperty(id,"scale","${markerOptions?.scale ?: scale}")
|
||||
}
|
||||
|
||||
fun getClickable(): Boolean {
|
||||
return markerOptions?.isClickable()!!
|
||||
return markerOptions.isClickable()!!
|
||||
}
|
||||
|
||||
fun setSaveBitmapEnable(enable: Boolean) {
|
||||
@@ -130,64 +128,64 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
|
||||
//设置marker是否需要显示动画
|
||||
fun setDisplayAnimEnable(enable: Boolean) {
|
||||
markerOptions?.displayAnimEnable(enable)
|
||||
markerOptions.displayAnimEnable(enable)
|
||||
mMapController?.updateAnchorProperty(id, "isDisplayAnim", "${enable}")
|
||||
}
|
||||
|
||||
//设置marker动画停顿帧数
|
||||
fun setAnimWaitFrame(animWaitFrame: Int) {
|
||||
markerOptions?.animWaitFrame(animWaitFrame)
|
||||
markerOptions.animWaitFrame(animWaitFrame)
|
||||
mMapController?.updateAnchorProperty(id, "animWaitFrame", "${animWaitFrame}")
|
||||
}
|
||||
|
||||
//设置marker动画资源
|
||||
fun setAnimResource(resId: Int) {
|
||||
markerOptions?.animMarkerRes(resId,mMapController)
|
||||
markerOptions?.animAnchorResource?.let{
|
||||
markerOptions.animMarkerRes(resId,mMapController)
|
||||
markerOptions.animAnchorResource.let{
|
||||
mMapController?.updateAnchorProperty(id, "animAnchorResource", it)
|
||||
}
|
||||
}
|
||||
|
||||
fun setAverageFlag(averageFlag: Int) {
|
||||
markerOptions?.averageFlag(averageFlag)
|
||||
markerOptions.averageFlag(averageFlag)
|
||||
mMapController?.updateAnchorProperty(id, "averageFlag", "${averageFlag}")
|
||||
}
|
||||
|
||||
//设置marker动画资源
|
||||
fun setAnimResourceStr(resStr: String) {
|
||||
markerOptions?.animAnchorResource = resStr;
|
||||
markerOptions.animAnchorResource = resStr;
|
||||
mMapController?.updateAnchorProperty(id, "animAnchorResource", resStr)
|
||||
}
|
||||
|
||||
fun setAnimType(animType: Int) {
|
||||
markerOptions?.animType(animType)
|
||||
markerOptions.animType(animType)
|
||||
mMapController?.updateAnchorProperty(id, "animType", "$animType")
|
||||
}
|
||||
|
||||
fun setAnchorType(anchorType: Int) {
|
||||
markerOptions?.anchorType(anchorType)
|
||||
markerOptions.anchorType(anchorType)
|
||||
mMapController?.updateAnchorProperty(id, "anchorType", "$anchorType")
|
||||
}
|
||||
|
||||
fun setAnchorShadow(anchorShadow: Int) {
|
||||
markerOptions?.anchorShadow(anchorShadow)
|
||||
markerOptions.anchorShadow(anchorShadow)
|
||||
mMapController?.updateAnchorProperty(id, "anchorShadow", "$anchorShadow")
|
||||
}
|
||||
|
||||
fun setColorType(colorType: Int) {
|
||||
markerOptions?.colorType(colorType)
|
||||
markerOptions.colorType(colorType)
|
||||
mMapController?.updateAnchorProperty(id, "colorType", "$colorType")
|
||||
}
|
||||
|
||||
|
||||
fun setchangeColorTime(changeColorTime: Float) {
|
||||
markerOptions?.changeColorTime(changeColorTime)
|
||||
markerOptions.changeColorTime(changeColorTime)
|
||||
mMapController?.updateAnchorProperty(id, "changeColorTime", "$changeColorTime")
|
||||
}
|
||||
|
||||
|
||||
fun setChangeColorAngle(changeColorAngle: Float) {
|
||||
markerOptions?.changeColorAngle(changeColorAngle)
|
||||
markerOptions.changeColorAngle(changeColorAngle)
|
||||
mMapController?.updateAnchorProperty(id, "changeColorAngle", "$changeColorAngle")
|
||||
}
|
||||
|
||||
@@ -196,11 +194,11 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
*/
|
||||
fun setPosition(latLng: LonLatPoint): Boolean {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "autoop-markerop-setPosition-${latLng},mMarker:${markerOptions?.getId()}")
|
||||
Log.i(TAG, "autoop-markerop-setPosition-${latLng},mMarker:${markerOptions.getId()}")
|
||||
}
|
||||
markerOptions?.position(latLng)
|
||||
markerOptions.position(latLng)
|
||||
return mMapController?.updateAnchorProperty(id, "lonLatPoint",
|
||||
"${markerOptions?.getLonLatPoint()?.lon ?: latLng.longitude}, ${markerOptions?.getLonLatPoint()?.lat ?: latLng.latitude}")?:false
|
||||
"${markerOptions.getLonLatPoint()?.lon ?: latLng.longitude}, ${markerOptions.getLonLatPoint()?.lat ?: latLng.latitude}")?:false
|
||||
}
|
||||
|
||||
|
||||
@@ -209,9 +207,9 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
*/
|
||||
fun setPositionOnly(latLng: LonLatPoint) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "autoop-markerop-setPositionOnly-${latLng},mMarker:${markerOptions?.getId()}")
|
||||
Log.i(TAG, "autoop-markerop-setPositionOnly-${latLng},mMarker:${markerOptions.getId()}")
|
||||
}
|
||||
markerOptions?.position(latLng)
|
||||
markerOptions.position(latLng)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,11 +227,11 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
setPosition(CommonProxy.getInstance().getLonLatProxy().switchLonLat(it))
|
||||
}
|
||||
}
|
||||
return markerOptions?.getPosition()
|
||||
return markerOptions.getPosition()
|
||||
}
|
||||
|
||||
fun getLonLatOrigin(): LonLatPoint? {
|
||||
return markerOptions?.getLonLatOrigin()
|
||||
return markerOptions.getLonLatOrigin()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,7 +241,7 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
mHandler.removeCallbacksAndMessages(null)
|
||||
this.id = markerOptions.getId()?:""
|
||||
if (!TextUtils.isEmpty(id)) {
|
||||
markerOptions?.reset()
|
||||
markerOptions.reset()
|
||||
mMapController?.removeAnchor(id)
|
||||
mMarkerCall?.removeInfoViewClick(id)
|
||||
// RecycleController.instance.removeRender(id)
|
||||
@@ -267,9 +265,9 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
* 设置infowindow的标题
|
||||
*/
|
||||
fun setTitle(title: String) {
|
||||
markerOptions?.title(title)
|
||||
markerOptions.title(title)
|
||||
mMapController?.updateAnchorProperty(id, "title", title)
|
||||
if (markerOptions?.isInfoWindowEnable()!!) {
|
||||
if (markerOptions.isInfoWindowEnable()!!) {
|
||||
showInfoWindow()
|
||||
}
|
||||
}
|
||||
@@ -282,16 +280,16 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
* 设置infowindow的内容
|
||||
*/
|
||||
fun setSnippet(snippet: String) {
|
||||
markerOptions?.snippet(snippet)
|
||||
markerOptions.snippet(snippet)
|
||||
mMapController?.updateAnchorProperty(id, "snippet", snippet)
|
||||
if (markerOptions?.isInfoWindowEnable() ?: true) {
|
||||
if (markerOptions.isInfoWindowEnable() ?: true) {
|
||||
showInfoWindow()
|
||||
}
|
||||
}
|
||||
|
||||
//设置Marker覆盖物的InfoWindow是否允许显示,默认为false
|
||||
fun setInfoWindowEnable(isEnable: Boolean) {
|
||||
markerOptions?.infoWindowEnable(isEnable)
|
||||
markerOptions.infoWindowEnable(isEnable)
|
||||
mMapController?.updateAnchorProperty(id, "infoWindowEnable", "$isEnable")
|
||||
}
|
||||
|
||||
@@ -327,17 +325,17 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
* 更新marker的图片
|
||||
*/
|
||||
fun setIcon(bitmap: Bitmap) {
|
||||
markerOptions?.updateMarkerIcon(bitmap,mMapController)
|
||||
markerOptions.updateMarkerIcon(bitmap,mMapController)
|
||||
}
|
||||
|
||||
fun setIcon(view: View) {
|
||||
BitmapDescriptorFactory.fromView(view).bitmap?.let {
|
||||
markerOptions?.updateMarkerIcon(it,mMapController)
|
||||
markerOptions.updateMarkerIcon(it,mMapController)
|
||||
}
|
||||
}
|
||||
|
||||
fun marker3DIcon(resId: Int) {
|
||||
markerOptions?.marker3DIcon(resId,mMapController)?.let {
|
||||
markerOptions.marker3DIcon(resId,mMapController).let {
|
||||
setMarkerOptions(it)
|
||||
}
|
||||
}
|
||||
@@ -347,7 +345,7 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
* @param anchorV Marker覆盖物锚点在垂直范围的比例
|
||||
*/
|
||||
fun setAnchor(anchorU: Float, anchorV: Float) {
|
||||
markerOptions?.anchor(anchorU, anchorV)
|
||||
markerOptions.anchor(anchorU, anchorV)
|
||||
mMapController?.updateAnchorProperty(id, "anchorUV", "${anchorU},${anchorV}" )
|
||||
}
|
||||
|
||||
@@ -355,7 +353,7 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
* 隐藏infowindow
|
||||
*/
|
||||
fun hideInfoWindow() {
|
||||
markerOptions?.setInfoWindowShown(false)
|
||||
markerOptions.setInfoWindowShown(false)
|
||||
mMapController?.hideInfoWindow(id)
|
||||
}
|
||||
|
||||
@@ -363,14 +361,14 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
*返回Marker覆盖物的信息窗口是否显示,true: 显示,false: 不显示。
|
||||
*/
|
||||
fun isInfoWindowShown(): Boolean {
|
||||
return markerOptions?.isInfoWindowShown() ?: false
|
||||
return markerOptions.isInfoWindowShown() ?: false
|
||||
}
|
||||
|
||||
/**
|
||||
* marker是否可见
|
||||
*/
|
||||
fun setVisible(visible: Boolean) {
|
||||
markerOptions?.visible(visible)
|
||||
markerOptions.visible(visible)
|
||||
mMapController?.updateAnchorProperty(id, "visible",visible.toString())
|
||||
}
|
||||
|
||||
@@ -382,7 +380,7 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
* marker的图片旋转角度
|
||||
*/
|
||||
fun setRotateAngle(rotageAngle: Float) {
|
||||
markerOptions?.rotateAngle(rotageAngle)
|
||||
markerOptions.rotateAngle(rotageAngle)
|
||||
mMapController?.updateAnchorProperty(id,"rotateAngle","$rotageAngle")
|
||||
}
|
||||
|
||||
@@ -394,7 +392,7 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
* 设置marker的透明度
|
||||
*/
|
||||
fun setAlpha(alpha: Float) {
|
||||
markerOptions?.setAlpha(alpha)
|
||||
markerOptions.setAlpha(alpha)
|
||||
mMapController?.updateAnchorProperty(id,"alpha","$alpha")
|
||||
}
|
||||
|
||||
@@ -404,18 +402,18 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
|
||||
//设置多少帧刷新一次图片资源,Marker动画的间隔时间,值越小动画越快。
|
||||
fun setPeriod(period: Int) {
|
||||
markerOptions?.period(period)
|
||||
markerOptions.period(period)
|
||||
mMapController?.updateAnchorProperty(id,"period","$period")
|
||||
}
|
||||
|
||||
//设置infowindow偏移量
|
||||
fun setInfoWindowOffset(offsetX: Int, offsetY: Int) {
|
||||
markerOptions?.setInfoWindowOffset(offsetX, offsetY)
|
||||
markerOptions.setInfoWindowOffset(offsetX, offsetY)
|
||||
mMapController?.setSomeAnchorInfowindowOffset(id, offsetX, offsetY)
|
||||
}
|
||||
|
||||
fun setInfoWindowView(infoView: View) {
|
||||
markerOptions?.updateInfowindowView(infoView,mMapController)
|
||||
markerOptions.updateInfowindowView(infoView,mMapController)
|
||||
}
|
||||
|
||||
//设置marker置顶
|
||||
@@ -429,7 +427,7 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
|
||||
//设置z轴的值
|
||||
fun setZIndex(zIndex: Int) {
|
||||
markerOptions?.zIndex(zIndex)
|
||||
markerOptions.zIndex(zIndex)
|
||||
mMapController?.setSomeAnchorZIndex(id, zIndex)
|
||||
}
|
||||
|
||||
@@ -439,19 +437,19 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
* @param color "#RRGGBBAA"
|
||||
*/
|
||||
fun setAnchorColor(color: String) {
|
||||
markerOptions?.anchorColor(color)
|
||||
markerOptions.anchorColor(color)
|
||||
mMapController?.updateAnchorProperty(id, "anchorColor", color)
|
||||
}
|
||||
|
||||
//设置marker是否可以拖拽
|
||||
fun setDraggable(isDraggable: Boolean) {
|
||||
markerOptions?.draggable(isDraggable)
|
||||
markerOptions.draggable(isDraggable)
|
||||
mMapController?.updateAnchorProperty(id!!, "draggable", "$isDraggable")
|
||||
}
|
||||
|
||||
//设置marker是否需要方向
|
||||
fun setControlAngle(enable: Boolean) {
|
||||
markerOptions?.controlAngle(enable)
|
||||
markerOptions.controlAngle(enable)
|
||||
mMapController?.updateAnchorProperty(id, "controlAngle", "$enable")
|
||||
}
|
||||
|
||||
@@ -498,23 +496,23 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
}
|
||||
|
||||
fun setGps(isGps: Boolean) {
|
||||
markerOptions?.setGps(isGps)
|
||||
markerOptions.setGps(isGps)
|
||||
}
|
||||
|
||||
fun setFlat(flat: Boolean) {
|
||||
markerOptions?.setFlat(flat)
|
||||
markerOptions.setFlat(flat)
|
||||
mMapController?.setSomeAnchorFlat(id, flat)
|
||||
}
|
||||
|
||||
fun isFlat(): Boolean {
|
||||
return markerOptions?.getFlat() ?: false
|
||||
return markerOptions.getFlat()
|
||||
}
|
||||
|
||||
fun setIcons(icons: ArrayList<*>) {
|
||||
if(icons.isEmpty()){
|
||||
return
|
||||
}
|
||||
var animation = MarkerFlashAnimation(icons)
|
||||
val animation = MarkerFlashAnimation(icons)
|
||||
animation.setDuration(getPeriod().toLong())
|
||||
setFlashAnimation(animation)
|
||||
startAnimation()
|
||||
@@ -522,7 +520,7 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
|
||||
//返回Marker动画帧的图标列表。
|
||||
fun getIcons(): ArrayList<String>? {
|
||||
return markerOptions?.getIcons()
|
||||
return markerOptions.getIcons()
|
||||
}
|
||||
|
||||
//设置marker覆盖物在屏幕的像素坐标
|
||||
@@ -532,14 +530,11 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
|
||||
//得到多少帧刷新一次图片资源
|
||||
fun getPeriod(): Int {
|
||||
return markerOptions?.period ?: 10
|
||||
return markerOptions.period ?: 10
|
||||
}
|
||||
|
||||
fun showInfoWindow() {
|
||||
var infoWindowAdapter = mMapController?.getMarkerController()?.getInfoWindow()
|
||||
if (infoWindowAdapter == null) {
|
||||
return
|
||||
}
|
||||
val infoWindowAdapter = mMapController?.getMarkerController()?.getInfoWindow() ?: return
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--matt--showInfoWindow--start:${id}")
|
||||
}
|
||||
@@ -548,17 +543,17 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--matt--showInfoWindow--view is not null")
|
||||
}
|
||||
var bitmapDescriptor = BitmapDescriptorFactory.fromView(it)
|
||||
val bitmapDescriptor = BitmapDescriptorFactory.fromView(it)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--bitmap:${bitmapDescriptor.getBytes().size},${id}")
|
||||
}
|
||||
markerOptions?.setInfoWindowShown(true)
|
||||
markerOptions?.infoWindowEnable(true)
|
||||
markerOptions.setInfoWindowShown(true)
|
||||
markerOptions.infoWindowEnable(true)
|
||||
|
||||
mMapController?.updateAnchorProperty(id, "infoWindowEnabled", "true")
|
||||
mMapController?.updateAnchorProperty(id, "isInfoWindowShown", "true")
|
||||
|
||||
markerOptions?.updateInfowindowBitmap(bitmapDescriptor,mMapController)
|
||||
markerOptions.updateInfowindowBitmap(bitmapDescriptor,mMapController)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--matt--showInfoWindow--bitmapDescriptor:${bitmapDescriptor.width},${bitmapDescriptor.height}")
|
||||
}
|
||||
@@ -579,22 +574,22 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
view.layoutParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,FrameLayout.LayoutParams.WRAP_CONTENT)
|
||||
view.textSize = 10.0f
|
||||
view.text = id
|
||||
view?.let {
|
||||
view.let {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--matt--showInfoWindow--view is not null")
|
||||
}
|
||||
var bitmapDescriptor = BitmapDescriptorFactory.fromView(it)
|
||||
val bitmapDescriptor = BitmapDescriptorFactory.fromView(it)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--bitmap:${bitmapDescriptor.getBytes().size},${id}")
|
||||
}
|
||||
markerOptions?.setInfoWindowShown(true)
|
||||
markerOptions?.infoWindowEnable(true)
|
||||
markerOptions.setInfoWindowShown(true)
|
||||
markerOptions.infoWindowEnable(true)
|
||||
|
||||
|
||||
mMapController?.updateAnchorProperty(id, "infoWindowEnabled", "true")
|
||||
mMapController?.updateAnchorProperty(id, "isInfoWindowShown", "true")
|
||||
|
||||
markerOptions?.updateInfowindowBitmap(bitmapDescriptor,mMapController)
|
||||
markerOptions.updateInfowindowBitmap(bitmapDescriptor,mMapController)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--matt--showInfoWindow--bitmapDescriptor:${bitmapDescriptor.width},${bitmapDescriptor.height}")
|
||||
}
|
||||
@@ -607,14 +602,11 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun dealInfoWindowViewClick(view: View) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--matt--dealInfoWindowViewClick-start")
|
||||
}
|
||||
if (view is ViewGroup) {
|
||||
view as ViewGroup
|
||||
for (index in 0 until view.childCount) {
|
||||
val child = view.getChildAt(index)
|
||||
if (child is ViewGroup) {
|
||||
@@ -639,13 +631,11 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun dealInfoWindowViewClick(view: View, left: Int, top: Int) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--matt--dealInfoWindowViewClick-start:${view},${left},${top}")
|
||||
}
|
||||
if (view is ViewGroup) {
|
||||
view as ViewGroup
|
||||
for (index in 0 until view.childCount) {
|
||||
val child = view.getChildAt(index)
|
||||
if (child.hasOnClickListeners()) {
|
||||
@@ -678,7 +668,7 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
if(lonLatPoint.longitude <=0 || lonLatPoint.latitude<=0){
|
||||
return
|
||||
}
|
||||
markerOptions?.let {
|
||||
markerOptions.let {
|
||||
|
||||
if(ruleAngle != -1f){
|
||||
val currentAngle = it.getRotateAngle()
|
||||
@@ -698,7 +688,7 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
}
|
||||
it.rotateAngle(lonLatPoint.angle.toFloat())
|
||||
|
||||
var lonlatpoints: ArrayList<LonLatPoint> = ArrayList()
|
||||
val lonlatpoints: ArrayList<LonLatPoint> = ArrayList()
|
||||
var nextLonLatPoint = LonLatPoint(lonLatPoint.longitude,lonLatPoint.latitude,lonLatPoint.altitude,lonLatPoint.angle)
|
||||
var dur = duration
|
||||
if(forecastMultiples > 1f){
|
||||
@@ -718,11 +708,9 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun setTranslateAnimation(animation: MarkerTranslateAnimation) {
|
||||
markerOptions?.let {
|
||||
var duration = animation.getDuration().toInt()
|
||||
markerOptions.let {
|
||||
val duration = animation.getDuration().toInt()
|
||||
addMarkerAnimation(animation)
|
||||
val data = MapTools.listToArray(animation.getLonlatPoint(), !(markerOptions?.isGps() ?: true))
|
||||
mMapController?.addTranslateAnimationToAnchor(id, data, duration)
|
||||
@@ -730,12 +718,11 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
}
|
||||
|
||||
fun setMarkerScaleAnimation(animation: MarkerScaleAnimation) {
|
||||
var duration = animation.getDuration().toInt()
|
||||
val duration = animation.getDuration().toInt()
|
||||
addMarkerAnimation(animation)
|
||||
mMapController?.addScaleAnimationToAnchor(id, animation.scaleStart, animation.scaleEnd, duration)
|
||||
}
|
||||
|
||||
|
||||
private fun addMarkerAnimation(animation: Animation) {
|
||||
animation.getAnimationListener()?.let {
|
||||
when (animation) {
|
||||
@@ -764,7 +751,7 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
* type 0 =全部,1=平移 2=缩放
|
||||
*/
|
||||
private fun dealMarkerAnimationListener(startOrFinish: Boolean, type: Int) {
|
||||
if (markerAnimationMap.isNullOrEmpty()) {
|
||||
if (markerAnimationMap.isEmpty()) {
|
||||
return
|
||||
}
|
||||
when (type) {
|
||||
@@ -781,7 +768,7 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
var msg = Message()
|
||||
val msg = Message()
|
||||
msg.what = MSG_DEAL_LISTENER
|
||||
msg.arg1 = type
|
||||
if (startOrFinish) {
|
||||
@@ -798,34 +785,34 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
|
||||
|
||||
private fun setFlashAnimation(animation: MarkerFlashAnimation) {
|
||||
var jsonObject = JSONObject()
|
||||
var jsonArray = JSONArray()
|
||||
val jsonObject = JSONObject()
|
||||
val jsonArray = JSONArray()
|
||||
val duration = animation.getDuration().toInt()
|
||||
if(markerOptions?.vrIcon!!) {
|
||||
if(markerOptions.vrIcon) {
|
||||
val icons3D = animation.getIcons() as ArrayList<Int>
|
||||
if (icons3D != null && icons3D.size <= 10 && icons3D.size > 0) {
|
||||
if (icons3D.size <= 10 && icons3D.size > 0) {
|
||||
for (icon in icons3D) {
|
||||
mMapController?.getContext()?.let {context->
|
||||
var markerView = BitmapDescriptorFactory.from3DResource(context, icon)
|
||||
val markerView = BitmapDescriptorFactory.from3DResource(context, icon)
|
||||
markerView?.let {
|
||||
MD5Utils.getInstanse()
|
||||
var anchor3dName = MD5Utils.getMD5String(markerView)
|
||||
val markerIconName = anchor3dName
|
||||
if (!(mMarkerCall?.containMarkerIcon(markerIconName)?:true)) {
|
||||
val anchor3dName = MD5Utils.getMD5String(markerView)
|
||||
if (mMarkerCall?.containMarkerIcon(anchor3dName) == false) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--marker3DIcon--addImagetoImageManager:${markerIconName},${markerView.size}")
|
||||
Log.i(TAG,
|
||||
"markerop--marker3DIcon--addImagetoImageManager:$anchor3dName,${markerView.size}")
|
||||
}
|
||||
val result = mMapController?.addImage(
|
||||
markerIconName,
|
||||
anchor3dName,
|
||||
markerView,
|
||||
markerView.size,
|
||||
0
|
||||
)?:-1
|
||||
if (result == 0) {
|
||||
mMarkerCall?.addMarkerIcon(markerIconName)
|
||||
mMarkerCall?.addMarkerIcon(anchor3dName)
|
||||
}
|
||||
}
|
||||
jsonArray.put(markerIconName)
|
||||
jsonArray.put(anchor3dName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -837,10 +824,10 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
val icons = animation.getIcons() as ArrayList<BitmapDescriptor>
|
||||
if (icons != null) {
|
||||
for (icon in icons) {
|
||||
var markerView = icon.getBytes()
|
||||
val markerView = icon.getBytes()
|
||||
MD5Utils.getInstanse()
|
||||
var markerIconName = MD5Utils.getMD5String(markerView)
|
||||
if (!(mMarkerCall?.containMarkerIcon(markerIconName)?:true)) {
|
||||
val markerIconName = MD5Utils.getMD5String(markerView)
|
||||
if (mMarkerCall?.containMarkerIcon(markerIconName) == false) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--setIcon--addImagetoImageManager:${markerIconName}")
|
||||
}
|
||||
@@ -891,10 +878,10 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
|
||||
* @param angle 角度 范围(0,90,180,270)
|
||||
*/
|
||||
fun setMarkerFlash(colorType: Int, color: String, time: Float, angle: Float){
|
||||
markerOptions?.colorType(colorType)
|
||||
markerOptions?.anchorColor(color)
|
||||
markerOptions?.changeColorTime(time)
|
||||
markerOptions?.changeColorAngle(angle)
|
||||
markerOptions.colorType(colorType)
|
||||
markerOptions.anchorColor(color)
|
||||
markerOptions.changeColorTime(time)
|
||||
markerOptions.changeColorAngle(angle)
|
||||
mMapController?.setAnchorFlash(id, colorType, color, time, angle)
|
||||
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
if (dataStr == null || dataStr.length < 1) {
|
||||
return null
|
||||
}
|
||||
var dataStrTemp = dataStr.substring(0, dataStr.length - 1)
|
||||
val dataStrTemp = dataStr.substring(0, dataStr.length - 1)
|
||||
val array = dataStrTemp.split(",")
|
||||
if (array.isEmpty() || array.size % 7 != 0) {
|
||||
return null
|
||||
@@ -89,7 +89,7 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
val resultList = ArrayList<MarkerSimpleData>()
|
||||
|
||||
for (i in 0 until array.size step 7) {
|
||||
var markerSimpleData = MarkerSimpleData()
|
||||
val markerSimpleData = MarkerSimpleData()
|
||||
markerSimpleData.id = array[i].toLong()
|
||||
markerSimpleData.lon = array[i + 1].toDouble()
|
||||
markerSimpleData.lat = array[i + 2].toDouble()
|
||||
@@ -108,7 +108,7 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
// }
|
||||
// val temp = dataSet.copy()
|
||||
// val current = System.currentTimeMillis()
|
||||
// cacheMap.put(current,temp);
|
||||
// cacheMap.put(current,temp)
|
||||
// timeList.add(current)
|
||||
// if(CompileConfig.DEBUG){
|
||||
// Log.i(TAG, "MarkerRecycleController--cacheMap: ${cacheMap.size},timeList:${timeList.size},arrayList:${temp}")
|
||||
@@ -120,8 +120,8 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
var lastLat: Double = 0.0
|
||||
|
||||
fun addCache(dataSet: MarkerDataSet?) {
|
||||
if(taskJob == null){
|
||||
if(!isExecuting.get()){
|
||||
if (taskJob == null) {
|
||||
if (!isExecuting.get()) {
|
||||
execute()
|
||||
}
|
||||
}
|
||||
@@ -151,15 +151,15 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
val current = System.currentTimeMillis()
|
||||
timeList.add(current)
|
||||
// timeList.sort()
|
||||
cacheMap.put(current, temp);
|
||||
cacheMap.put(current, temp)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun addCache(originBatchData: MarkerBatchData?) {
|
||||
if(taskJob == null){
|
||||
if(!isExecuting.get()){
|
||||
if (taskJob == null) {
|
||||
if (!isExecuting.get()) {
|
||||
execute()
|
||||
}
|
||||
}
|
||||
@@ -169,19 +169,19 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
if (originBatchData == null) {
|
||||
return
|
||||
}
|
||||
var batchData = originBatchData.copy()
|
||||
val batchData = originBatchData.copy()
|
||||
val current = System.currentTimeMillis()
|
||||
val arrayList = batchData.others
|
||||
if (arrayList == null || arrayList.isEmpty()) {
|
||||
cacheDataSetMap.put(current, batchData)
|
||||
cacheDataSetMap[current] = batchData
|
||||
timeList.add(current)
|
||||
batchData.centerMarkerOptions?.let {
|
||||
val simpleData = MarkerSimpleData()
|
||||
simpleData?.lon = it.lon
|
||||
simpleData?.lat = it.lat
|
||||
simpleData?.alt = it.alt
|
||||
simpleData?.rotateAngle = it.rotateAngle
|
||||
simpleData?.time = current
|
||||
simpleData.lon = it.lon
|
||||
simpleData.lat = it.lat
|
||||
simpleData.alt = it.alt
|
||||
simpleData.rotateAngle = it.rotateAngle
|
||||
simpleData.time = current
|
||||
preMarkerMap[current] = simpleData
|
||||
}
|
||||
return
|
||||
@@ -195,20 +195,17 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
// duration = duration + INTERPOLATION_INTERVAL
|
||||
// }
|
||||
// }
|
||||
var size = timeList.size
|
||||
val size = timeList.size
|
||||
if (size >= 1 && lastPreTime > 0L) {
|
||||
var preTime = lastPreTime
|
||||
if (preTime > 0L) {
|
||||
var duration = INTERPOLATION_INTERVAL
|
||||
while ((preTime + duration) < current) {
|
||||
timeList.add(preTime + duration)
|
||||
duration = duration + INTERPOLATION_INTERVAL
|
||||
}
|
||||
val preTime = lastPreTime
|
||||
var duration = INTERPOLATION_INTERVAL
|
||||
while ((preTime + duration) < current) {
|
||||
timeList.add(preTime + duration)
|
||||
duration += INTERPOLATION_INTERVAL
|
||||
}
|
||||
}
|
||||
//按照时间存储他车补帧数据
|
||||
val interpolationDataSetMap: HashMap<Long, ArrayList<MarkerSimpleData>> =
|
||||
HashMap<Long, ArrayList<MarkerSimpleData>>()
|
||||
val interpolationDataSetMap: HashMap<Long, ArrayList<MarkerSimpleData>> = HashMap()
|
||||
batchData.centerMarkerOptions?.time = current
|
||||
lastPreTime = current
|
||||
for (markerOptions in arrayList) {
|
||||
@@ -228,7 +225,7 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
|
||||
if (preMarkerMap.containsKey(id)) {
|
||||
// pre data
|
||||
val preMarkerOptions = preMarkerMap.get(id)!!
|
||||
val preMarkerOptions = preMarkerMap[id]!!
|
||||
// 距离
|
||||
val disInterval = MathUtils.distance(
|
||||
preMarkerOptions.lon,
|
||||
@@ -247,7 +244,7 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
if (time < preMarkerOptions.time) {
|
||||
continue
|
||||
}
|
||||
var duration = (time - preMarkerOptions.time).toInt()
|
||||
val duration = (time - preMarkerOptions.time).toInt()
|
||||
|
||||
// 每次插值离首点(pre)距离
|
||||
val stepDistance = (disInterval * duration) / timeInterval.toDouble()
|
||||
@@ -278,12 +275,12 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
tempSimpleData.color = markerSimpleData.color
|
||||
tempSimpleData.text = markerSimpleData.text
|
||||
tempSimpleData.status = markerSimpleData.status
|
||||
var tempList = interpolationDataSetMap.get(time)
|
||||
var tempList = interpolationDataSetMap[time]
|
||||
if (tempList == null) {
|
||||
tempList = ArrayList<MarkerSimpleData>()
|
||||
tempList = ArrayList()
|
||||
}
|
||||
tempList.add(tempSimpleData)
|
||||
interpolationDataSetMap.put(time, tempList)
|
||||
interpolationDataSetMap[time] = tempList
|
||||
}
|
||||
|
||||
}
|
||||
@@ -291,7 +288,7 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
}
|
||||
|
||||
for ((key, list) in interpolationDataSetMap) {
|
||||
var markerBatchData = cacheDataSetMap.get(key)
|
||||
var markerBatchData = cacheDataSetMap[key]
|
||||
if (markerBatchData == null) {
|
||||
markerBatchData = MarkerBatchData()
|
||||
markerBatchData.centerMarkerOptions =
|
||||
@@ -315,7 +312,7 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
interpolationDataSetMap.clear()
|
||||
timeList.add(current)
|
||||
// timeList.sort()
|
||||
cacheDataSetMap.put(current, batchData)
|
||||
cacheDataSetMap[current] = batchData
|
||||
val preIt = preMarkerMap.keys.iterator()
|
||||
while (preIt.hasNext()) {
|
||||
val key = preIt.next()
|
||||
@@ -329,11 +326,11 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
}
|
||||
batchData.centerMarkerOptions?.let {
|
||||
val simpleData = MarkerSimpleData()
|
||||
simpleData?.lon = it.lon
|
||||
simpleData?.lat = it.lat
|
||||
simpleData?.alt = it.alt
|
||||
simpleData?.rotateAngle = it.rotateAngle
|
||||
simpleData?.time = current
|
||||
simpleData.lon = it.lon
|
||||
simpleData.lat = it.lat
|
||||
simpleData.alt = it.alt
|
||||
simpleData.rotateAngle = it.rotateAngle
|
||||
simpleData.time = current
|
||||
// simpleData?.markerType = it.markerIconName.toInt()
|
||||
selfMarkerMap.put(current, simpleData)
|
||||
}
|
||||
@@ -361,9 +358,9 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
current: Long,
|
||||
markerSimpleOptions: MarkerSimpleOptions?
|
||||
): MarkerSimpleOptions? {
|
||||
var choiceKey: Long = 0L
|
||||
for ((key, value) in selfMarkerMap) {
|
||||
if (key <= time && key >= current) {
|
||||
var choiceKey = 0L
|
||||
for ((key, _) in selfMarkerMap) {
|
||||
if (key in current..time) {
|
||||
if (choiceKey == 0L) {
|
||||
choiceKey = key
|
||||
} else {
|
||||
@@ -377,7 +374,7 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
if (choiceKey == 0L || markerSimpleOptions == null) {
|
||||
return markerSimpleOptions
|
||||
}
|
||||
val selfMarkerSimpleData = selfMarkerMap.get(choiceKey)
|
||||
val selfMarkerSimpleData = selfMarkerMap[choiceKey]
|
||||
|
||||
selfMarkerSimpleData?.let {
|
||||
// 距离
|
||||
@@ -396,7 +393,7 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
interMarker.time = time
|
||||
return interMarker
|
||||
}
|
||||
if (duration > 0 && duration < timeInterval) {
|
||||
if (duration in 1 until timeInterval) {
|
||||
// 每次插值离首点(pre)距离
|
||||
val stepDistance = (disInterval * duration) / timeInterval.toDouble()
|
||||
|
||||
@@ -499,14 +496,14 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "updateMarker:others: ${batchData.others?.size}")
|
||||
}
|
||||
if (mLastLocationTime > 0L) {
|
||||
duration = (System.currentTimeMillis() - mLastLocationTime).toInt()
|
||||
duration = if (mLastLocationTime > 0L) {
|
||||
(System.currentTimeMillis() - mLastLocationTime).toInt()
|
||||
} else {
|
||||
duration = 100;
|
||||
100
|
||||
}
|
||||
mLastLocationTime = System.currentTimeMillis()
|
||||
if (batchData.others != null) {
|
||||
val list = ArrayList(batchData.others)
|
||||
val list = ArrayList(batchData.others!!)
|
||||
val batchMarkerOptions = BatchMarkerOptions()
|
||||
batchMarkerOptions.list = list
|
||||
batchMarkerOptions.delayStrategy = delayStrategy
|
||||
@@ -542,16 +539,16 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
return
|
||||
}
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "MarkerRecycleController--updateMarker: ${dataSet}")
|
||||
Log.i(TAG, "MarkerRecycleController--updateMarker: $dataSet")
|
||||
}
|
||||
var localDataSet = dataSet.copy()
|
||||
val localDataSet = dataSet.copy()
|
||||
if (localDataSet.others == null) {
|
||||
return
|
||||
}
|
||||
if (mLastLocationTime > 0L) {
|
||||
duration = (System.currentTimeMillis() - mLastLocationTime).toInt()
|
||||
} else {
|
||||
duration = 100;
|
||||
duration = 100
|
||||
}
|
||||
mLastLocationTime = System.currentTimeMillis()
|
||||
val satelliteTime: Long =
|
||||
@@ -575,7 +572,7 @@ class MarkerCacheController(private val mapAutoView: MapAutoView) {
|
||||
lonLatPoint.angle = markerOptions.rotateAngle.toDouble()
|
||||
lonLatPoint.speed = markerOptions.speed
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "MarkerRecycleController--updateMarker: ${lonLatPoint}")
|
||||
Log.i(TAG, "MarkerRecycleController--updateMarker: $lonLatPoint")
|
||||
}
|
||||
mapAutoView.getLocationClient()?.updateLocation(lonLatPoint)
|
||||
}
|
||||
|
||||
@@ -16,39 +16,30 @@ import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
|
||||
|
||||
class MarkerController: IMarkerController {
|
||||
class MarkerController(mapController: IMapController) : IMarkerController {
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
|
||||
private lateinit var mMapController: IMapController
|
||||
private lateinit var mMarkerCall: IMarkerCall
|
||||
|
||||
constructor(mapController: IMapController){
|
||||
this.mMapController = mapController
|
||||
this.mMarkerCall = MarkerNativeInterface(mMapController)
|
||||
this.mMapController.setMarkerCall(this.mMarkerCall)
|
||||
}
|
||||
|
||||
|
||||
private val mMapController: IMapController = mapController
|
||||
private val mMarkerCall: IMarkerCall = MarkerNativeInterface(mMapController)
|
||||
private var mLastBatchSatelliteTime:Long = 0L
|
||||
|
||||
private var infoWindowAdapter: InfoWindowAdapter? = null
|
||||
|
||||
override fun setInfoWindow(infoWindowAdapter: InfoWindowAdapter) {
|
||||
mMapController?.getClerk()?.add()
|
||||
mMapController.getClerk()?.add()
|
||||
this.infoWindowAdapter = infoWindowAdapter
|
||||
}
|
||||
|
||||
override fun getInfoWindow(): InfoWindowAdapter? {
|
||||
mMapController?.getClerk()?.add()
|
||||
mMapController.getClerk()?.add()
|
||||
return infoWindowAdapter
|
||||
}
|
||||
|
||||
override fun addMarker(markerOptions: MarkerOptions): Marker? {
|
||||
mMapController?.getClerk()?.add("$markerOptions")
|
||||
var marker: Marker
|
||||
var isSuccess = false
|
||||
var jsonStr = toJson(markerOptions)
|
||||
mMapController.getClerk()?.add("$markerOptions")
|
||||
val marker: Marker
|
||||
val isSuccess: Boolean
|
||||
val jsonStr = toJson(markerOptions)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "markerop--addMarker:${jsonStr}")
|
||||
}
|
||||
@@ -57,7 +48,7 @@ class MarkerController: IMarkerController {
|
||||
byteArrayOf(),
|
||||
0,
|
||||
0
|
||||
) ?: false
|
||||
)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "markerop--addMarker:over--shakeSceneManual")
|
||||
}
|
||||
@@ -66,8 +57,8 @@ class MarkerController: IMarkerController {
|
||||
// RecycleController.instance.addRender(markerOptions.getId())
|
||||
val icons = marker.getIcons()
|
||||
if(icons != null){
|
||||
var jsonObject = JSONObject()
|
||||
var jsonArray = JSONArray(icons)
|
||||
val jsonObject = JSONObject()
|
||||
val jsonArray = JSONArray(icons)
|
||||
jsonObject.put("images", jsonArray)
|
||||
val images = jsonObject.toString()
|
||||
marker.getId()?.let {
|
||||
@@ -88,7 +79,7 @@ class MarkerController: IMarkerController {
|
||||
|
||||
|
||||
override fun addSelfCar(markerOptions: MarkerOptions): Marker? {
|
||||
mMapController?.getClerk()?.add()
|
||||
mMapController.getClerk()?.add()
|
||||
val jsonStr = toJson(markerOptions)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "autoop--selfop---markerop--addSelfCar: ${jsonStr}")
|
||||
@@ -96,18 +87,17 @@ class MarkerController: IMarkerController {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "autoop--selfop---markerop--addSelfCar mapView is not null")
|
||||
}
|
||||
val flag = mMapController.createConstAnchor(
|
||||
val flag = mMapController.createConstAnchor(
|
||||
jsonStr,
|
||||
byteArrayOf(),
|
||||
0,
|
||||
0
|
||||
)?: false
|
||||
)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "autoop--selfop---markerop--addSelfCar ${flag}")
|
||||
}
|
||||
if(flag){
|
||||
var marker = Marker(markerOptions,mMapController, mMarkerCall)
|
||||
return marker
|
||||
if(flag) {
|
||||
return Marker(markerOptions, mMapController, mMarkerCall)
|
||||
}
|
||||
return null
|
||||
|
||||
@@ -115,11 +105,11 @@ class MarkerController: IMarkerController {
|
||||
|
||||
//添加多个锚点
|
||||
override fun addMarkers(multiPointOverlayOptions: MultiPointOverlayOptions): MultiPointController {
|
||||
mMapController?.getClerk()?.add()
|
||||
mMapController.getClerk()?.add()
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--addMarkers::multiPointOverlayOptions:${multiPointOverlayOptions}")
|
||||
}
|
||||
var strJson = toJson(multiPointOverlayOptions)
|
||||
val strJson = toJson(multiPointOverlayOptions)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--addMarkers--toJson:${strJson}")
|
||||
}
|
||||
@@ -127,8 +117,7 @@ class MarkerController: IMarkerController {
|
||||
strJson,
|
||||
multiPointOverlayOptions.data.size
|
||||
)
|
||||
var multiPointController = MultiPointController(multiPointOverlayOptions)
|
||||
return multiPointController
|
||||
return MultiPointController(multiPointOverlayOptions)
|
||||
}
|
||||
|
||||
private fun toJson(markersController: MultiPointOverlayOptions): String {
|
||||
@@ -138,28 +127,27 @@ class MarkerController: IMarkerController {
|
||||
|
||||
|
||||
override fun destory(){
|
||||
mMapController?.getClerk()?.add()
|
||||
mMapController.getClerk()?.add()
|
||||
mMarkerCall.exit()
|
||||
infoWindowAdapter = null
|
||||
}
|
||||
|
||||
override fun removeMarker(id:String){
|
||||
mMapController?.getClerk()?.add("$id")
|
||||
mMapController.getClerk()?.add(id)
|
||||
mMapController.removeAnchor(id)
|
||||
mMarkerCall?.removeInfoViewClick(id)
|
||||
mMarkerCall.removeInfoViewClick(id)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量更新他车
|
||||
*/
|
||||
override fun updateBatchMarkerPositon(batchMarkerOptions: BatchMarkerOptions){
|
||||
mMapController?.getClerk()?.add("${batchMarkerOptions.list?.size},${batchMarkerOptions.othersStr.length}")
|
||||
mMapController.getClerk()?.add("${batchMarkerOptions.list?.size},${batchMarkerOptions.othersStr.length}")
|
||||
|
||||
var otherStr = batchMarkerOptions.othersStr
|
||||
var duration:Int = batchMarkerOptions.duration
|
||||
|
||||
if(batchMarkerOptions.list?.isNotEmpty()?:false){
|
||||
if(batchMarkerOptions.list?.isNotEmpty() == true){
|
||||
val otherBuffer = StringBuffer()
|
||||
batchMarkerOptions.list?.let {
|
||||
for(markerOption in it){
|
||||
@@ -222,14 +210,13 @@ class MarkerController: IMarkerController {
|
||||
mMapController.updateBatchAnchorPositon(buffer.toString())
|
||||
}
|
||||
|
||||
var isUpdate = false;
|
||||
var driverTme :Long= 0;
|
||||
var isUpdate = false
|
||||
var driverTme :Long= 0
|
||||
var renderListener :OnRenderListener? = null
|
||||
|
||||
|
||||
//预添加车辆模型
|
||||
override fun addPreVehicleModel(type:Int,modelRes:Int):String?{
|
||||
mMapController?.getClerk()?.add("$type,$modelRes")
|
||||
mMapController.getClerk()?.add("$type,$modelRes")
|
||||
|
||||
val modelKey ="vehicle_${type}"
|
||||
if(mMarkerCall.containMarkerIcon(modelKey)){
|
||||
@@ -239,7 +226,7 @@ class MarkerController: IMarkerController {
|
||||
return modelKey
|
||||
}
|
||||
}
|
||||
var markerView = OperationUtils.fromRawResource(modelRes,mMapController.getContext())
|
||||
val markerView = OperationUtils.fromRawResource(modelRes,mMapController.getContext())
|
||||
if(markerView != null){
|
||||
mMarkerCall.addMarkerIconCache(modelRes,modelKey)
|
||||
val result = mMapController.addImage(
|
||||
@@ -247,27 +234,25 @@ class MarkerController: IMarkerController {
|
||||
markerView,
|
||||
markerView.size,
|
||||
0
|
||||
)?:-1
|
||||
if (result == 0) {
|
||||
)
|
||||
return if (result == 0) {
|
||||
mMarkerCall.addMarkerIcon(modelKey)
|
||||
return modelKey
|
||||
modelKey
|
||||
}else{
|
||||
return null
|
||||
null
|
||||
}
|
||||
}else{
|
||||
return null
|
||||
}
|
||||
|
||||
return modelKey
|
||||
}
|
||||
|
||||
//添加普通模型
|
||||
override fun addPreModel(modelRes:Int):String?{
|
||||
mMapController?.getClerk()?.add()
|
||||
mMapController.getClerk()?.add()
|
||||
if(mMarkerCall.containMarkerIconCache(modelRes)){
|
||||
return mMarkerCall.getMarkerIconCache(modelRes)
|
||||
}
|
||||
var markerView = OperationUtils.fromRawResource(modelRes,mMapController.getContext())
|
||||
val markerView = OperationUtils.fromRawResource(modelRes,mMapController.getContext())
|
||||
if(markerView != null){
|
||||
MD5Utils.getInstanse()
|
||||
val modelKey = MD5Utils.getMD5String(markerView)
|
||||
@@ -279,19 +264,18 @@ class MarkerController: IMarkerController {
|
||||
markerView,
|
||||
markerView.size,
|
||||
0
|
||||
)?:-1
|
||||
if (result == 0) {
|
||||
)
|
||||
return if (result == 0) {
|
||||
mMarkerCall.addMarkerIcon(modelKey)
|
||||
return modelKey
|
||||
modelKey
|
||||
}else{
|
||||
return null
|
||||
null
|
||||
}
|
||||
}
|
||||
return modelKey
|
||||
}else{
|
||||
return null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,5 +308,9 @@ class MarkerController: IMarkerController {
|
||||
return CarManager.checkCollision(selfLon,selfLat,list,mMapController)
|
||||
}
|
||||
|
||||
init {
|
||||
this.mMapController.setMarkerCall(this.mMarkerCall)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
package com.zhidaoauto.map.sdk.open.marker
|
||||
|
||||
|
||||
class MarkerFlashAnimation: Animation {
|
||||
private var icons: ArrayList<*>? = null
|
||||
class MarkerFlashAnimation(icons: ArrayList<*>) : Animation() {
|
||||
private var icons: ArrayList<*>? = icons
|
||||
private var duration:Long = 0
|
||||
|
||||
constructor(icons: ArrayList<*>){
|
||||
this.icons = icons
|
||||
}
|
||||
fun setDuration(duration: Long) {
|
||||
this.duration =duration
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class MarkerOptions {
|
||||
private var rotateAngle: Float = 0f
|
||||
|
||||
@JSONField(name = "markerInfoUseCache")
|
||||
private var markerInfoUseCache: Boolean = false;
|
||||
private var markerInfoUseCache: Boolean = false
|
||||
|
||||
@JSONField(name = "infoWindowEnabled")
|
||||
private var infoWindowEnabled: Boolean = true
|
||||
@@ -196,8 +196,8 @@ class MarkerOptions {
|
||||
|
||||
|
||||
fun updateInfowindowBitmap(markerInfoBitmap: BitmapDescriptor,mapController: IMapController?): MarkerOptions {
|
||||
var markerInfoView = markerInfoBitmap.getBytes()
|
||||
if(markerInfoView.size == 0){
|
||||
val markerInfoView = markerInfoBitmap.getBytes()
|
||||
if(markerInfoView.isEmpty()){
|
||||
return this
|
||||
}
|
||||
MD5Utils.getInstanse()
|
||||
@@ -224,10 +224,10 @@ class MarkerOptions {
|
||||
}
|
||||
|
||||
fun markerIcon(bitmap: Bitmap,mapController: IMapController?): MarkerOptions {
|
||||
var markerBitmap = BitmapDescriptorFactory.fromBitmap(bitmap)
|
||||
var markerView = markerBitmap.getBytes()
|
||||
val markerBitmap = BitmapDescriptorFactory.fromBitmap(bitmap)
|
||||
val markerView = markerBitmap.getBytes()
|
||||
MD5Utils.getInstanse()
|
||||
var markerIconName = MD5Utils.getMD5String(markerView)
|
||||
val markerIconName = MD5Utils.getMD5String(markerView)
|
||||
this.markerIconName = markerIconName
|
||||
this.vrIcon = false
|
||||
if (CompileConfig.DEBUG) {
|
||||
@@ -278,9 +278,9 @@ class MarkerOptions {
|
||||
}
|
||||
|
||||
fun markerIcon(markerBitmap: BitmapDescriptor,mapController: IMapController?): MarkerOptions {
|
||||
var markerView = markerBitmap.getBytes()
|
||||
val markerView = markerBitmap.getBytes()
|
||||
MD5Utils.getInstanse()
|
||||
var markerIconName = MD5Utils.getMD5String(markerView)
|
||||
val markerIconName = MD5Utils.getMD5String(markerView)
|
||||
this.markerIconName = markerIconName
|
||||
this.vrIcon = false
|
||||
addImageLogic(markerIconName, markerView, markerBitmap.width, markerBitmap.height,mapController)
|
||||
@@ -297,59 +297,57 @@ class MarkerOptions {
|
||||
|
||||
fun icons(icons: ArrayList<*>,mapController: IMapController?): MarkerOptions {
|
||||
this.icons.clear()
|
||||
if (icons != null && icons.size > 0) {
|
||||
if (icons.size > 0) {
|
||||
if(vrIcon){
|
||||
if(icons.size > 10){
|
||||
throw RuntimeException("最多支持10个3D模型")
|
||||
}else {
|
||||
for (icon in icons as ArrayList<Int>) {
|
||||
mapController?.getContext()?.let {
|
||||
var markerView = BitmapDescriptorFactory.from3DResource(it, icon)
|
||||
val markerView = BitmapDescriptorFactory.from3DResource(it, icon)
|
||||
markerView?.let {
|
||||
MD5Utils.getInstanse()
|
||||
var anchor3dName = MD5Utils.getMD5String(markerView)
|
||||
val markerIconName = anchor3dName
|
||||
this.icons.add(markerIconName)
|
||||
if (!(mapController.getMarkerCall()?.containMarkerIcon(markerIconName)?:true)) {
|
||||
val anchor3dName = MD5Utils.getMD5String(markerView)
|
||||
this.icons.add(anchor3dName)
|
||||
if (mapController.getMarkerCall()?.containMarkerIcon(anchor3dName) == false) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--marker3DIcon--addImagetoImageManager:${markerIconName},${markerView.size}")
|
||||
Log.i(TAG,
|
||||
"markerop--marker3DIcon--addImagetoImageManager:$anchor3dName,${markerView.size}")
|
||||
}
|
||||
val result = mapController?.addImage(
|
||||
markerIconName,
|
||||
val result = mapController.addImage(
|
||||
anchor3dName,
|
||||
markerView,
|
||||
markerView.size,
|
||||
0
|
||||
) ?: -1
|
||||
)
|
||||
if (result == 0) {
|
||||
mapController.getMarkerCall()?.addMarkerIcon(markerIconName)
|
||||
mapController.getMarkerCall()?.addMarkerIcon(anchor3dName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
for (icon in icons as ArrayList<BitmapDescriptor> ) {
|
||||
var markerView = icon.getBytes()
|
||||
val markerView = icon.getBytes()
|
||||
MD5Utils.getInstanse()
|
||||
var markerIconName = MD5Utils.getMD5String(markerView)
|
||||
val markerIconName = MD5Utils.getMD5String(markerView)
|
||||
this.icons.add(markerIconName)
|
||||
if (!(mapController?.getMarkerCall()?.containMarkerIcon(markerIconName)?:true)) {
|
||||
if (mapController?.getMarkerCall()?.containMarkerIcon(markerIconName) == false) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--setIcon--addImagetoImageManager:${markerIconName}")
|
||||
}
|
||||
val result = mapController?.addImage(
|
||||
val result = mapController.addImage(
|
||||
markerIconName,
|
||||
markerView, icon.width, icon.height
|
||||
)?:-1
|
||||
)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--setIcon--addImagetoImageManager:${markerIconName},result:${result},threadop:${Thread.currentThread().id}")
|
||||
}
|
||||
if (result == 0) {
|
||||
mapController?.getMarkerCall()?.addMarkerIcon(markerIconName)
|
||||
mapController.getMarkerCall()?.addMarkerIcon(markerIconName)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -360,27 +358,25 @@ class MarkerOptions {
|
||||
}
|
||||
|
||||
fun getIcons(): ArrayList<String>? {
|
||||
return if (!icons.isEmpty()) {
|
||||
icons
|
||||
} else {
|
||||
return icons.ifEmpty {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun markerIcon(resId: Int,mapController: IMapController?): MarkerOptions {
|
||||
if(mapController?.getMarkerCall()?.containMarkerIconCache(resId)?:false){
|
||||
this.markerIconName = mapController?.getMarkerCall()?.getMarkerIconCache(resId)?:""
|
||||
if(mapController?.getMarkerCall()?.containMarkerIconCache(resId) == true){
|
||||
this.markerIconName = mapController.getMarkerCall()?.getMarkerIconCache(resId)?:""
|
||||
this.vrIcon = false
|
||||
return this
|
||||
}
|
||||
mapController?.getContext()?.let {
|
||||
var markerBitmap = BitmapDescriptorFactory.fromResource(it, resId)
|
||||
var markerView = markerBitmap.getBytes()
|
||||
val markerBitmap = BitmapDescriptorFactory.fromResource(it, resId)
|
||||
val markerView = markerBitmap.getBytes()
|
||||
MD5Utils.getInstanse()
|
||||
var markerIconName = MD5Utils.getMD5String(markerView)
|
||||
val markerIconName = MD5Utils.getMD5String(markerView)
|
||||
this.markerIconName = markerIconName
|
||||
this.vrIcon = false
|
||||
mapController?.getMarkerCall()?.addMarkerIconCache(resId,markerIconName)
|
||||
mapController.getMarkerCall()?.addMarkerIconCache(resId,markerIconName)
|
||||
addImageLogic(markerIconName, markerView, markerBitmap.width, markerBitmap.height,mapController)
|
||||
}
|
||||
|
||||
@@ -407,27 +403,27 @@ class MarkerOptions {
|
||||
|
||||
if(markerView != null) {
|
||||
MD5Utils.getInstanse()
|
||||
var anchor3dName = MD5Utils.getMD5String(markerView)
|
||||
val anchor3dName = MD5Utils.getMD5String(markerView)
|
||||
|
||||
if (!(mapController?.getMarkerCall()?.containMarkerIcon(anchor3dName)?:true)) {
|
||||
if (mapController?.getMarkerCall()?.containMarkerIcon(anchor3dName) == false) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--marker3DIcon--addImagetoImageManager:${resId},${anchor3dName},${markerView!!
|
||||
.size}")
|
||||
}
|
||||
val result = mapController?.addImage(
|
||||
val result = mapController.addImage(
|
||||
anchor3dName,
|
||||
markerView!!,
|
||||
markerView!!.size,
|
||||
0
|
||||
)?:-1
|
||||
)
|
||||
if (result == 0 || result == 10003) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--marker3DIcon--addImagetoImageManager:success:${resId},${anchor3dName}")
|
||||
}
|
||||
this.markerIconName = anchor3dName
|
||||
this.vrIcon = true
|
||||
mapController?.getMarkerCall()?.addMarkerIconCache(resId,anchor3dName)
|
||||
mapController?.getMarkerCall()?.addMarkerIcon(anchor3dName)
|
||||
mapController.getMarkerCall()?.addMarkerIconCache(resId,anchor3dName)
|
||||
mapController.getMarkerCall()?.addMarkerIcon(anchor3dName)
|
||||
}
|
||||
}else{
|
||||
this.markerIconName = anchor3dName
|
||||
@@ -439,39 +435,39 @@ class MarkerOptions {
|
||||
Log.i(TAG, "markerop--marker3DIcon--addImagetoImageManager:fail:${resId}")
|
||||
}
|
||||
}
|
||||
return this;
|
||||
return this
|
||||
}
|
||||
|
||||
fun animMarkerRes(resId: Int,mapController: IMapController?): MarkerOptions {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--animMarkerRes--start: ${resId}")
|
||||
}
|
||||
if(mapController?.getMarkerCall()?.containMarkerIconCache(resId)?:false){
|
||||
this.animAnchorResource = mapController?.getMarkerCall()?.getMarkerIconCache(resId)?:""
|
||||
if(mapController?.getMarkerCall()?.containMarkerIconCache(resId) == true){
|
||||
this.animAnchorResource = mapController.getMarkerCall()?.getMarkerIconCache(resId)?:""
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--animMarkerRes--cache:${resId},${animAnchorResource}")
|
||||
}
|
||||
return this
|
||||
}
|
||||
var markerView = OperationUtils.fromRawResource(resId,mapController?.getContext())
|
||||
val markerView = OperationUtils.fromRawResource(resId,mapController?.getContext())
|
||||
if(markerView != null) {
|
||||
MD5Utils.getInstanse()
|
||||
var anchor3dName = MD5Utils.getMD5String(markerView)
|
||||
val anchor3dName = MD5Utils.getMD5String(markerView)
|
||||
|
||||
if (!(mapController?.getMarkerCall()?.containMarkerIcon(anchor3dName)?:true)) {
|
||||
val result = mapController?.addImage(
|
||||
if (mapController?.getMarkerCall()?.containMarkerIcon(anchor3dName) == false) {
|
||||
val result = mapController.addImage(
|
||||
anchor3dName,
|
||||
markerView,
|
||||
markerView.size,
|
||||
0
|
||||
)?:-1
|
||||
)
|
||||
if (result == 0 || result == 10003 ) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--animMarkerRes--addImagetoImageManager:success:${resId},${anchor3dName}")
|
||||
}
|
||||
this.animAnchorResource = anchor3dName
|
||||
mapController?.getMarkerCall()?.addMarkerIconCache(resId,animAnchorResource)
|
||||
mapController?.getMarkerCall()?.addMarkerIcon(animAnchorResource)
|
||||
mapController.getMarkerCall()?.addMarkerIconCache(resId,animAnchorResource)
|
||||
mapController.getMarkerCall()?.addMarkerIcon(animAnchorResource)
|
||||
}
|
||||
}else{
|
||||
if (CompileConfig.DEBUG) {
|
||||
@@ -485,15 +481,11 @@ class MarkerOptions {
|
||||
Log.i(TAG, "markerop--animMarkerRes--addImagetoImageManager:fail:${resId}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return this;
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun addImageLogic(markerIconName: String, imageByteArray: ByteArray, width: Int, height: Int,mapController: IMapController?) {
|
||||
if (!(mapController?.getMarkerCall()?.containMarkerIcon(markerIconName)?:false)) {
|
||||
if (mapController?.getMarkerCall()?.containMarkerIcon(markerIconName) != true) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop--setIcon--addImagetoImageManager:${markerIconName}")
|
||||
}
|
||||
@@ -525,7 +517,7 @@ class MarkerOptions {
|
||||
fun position(lonLatPoint: LonLatPoint): MarkerOptions {
|
||||
if(!MapDataApi.isRightLonLat(lonLatPoint.longitude,lonLatPoint.latitude)){
|
||||
Log.e(TAG, "position is error :${lonLatPoint.longitude},${lonLatPoint.latitude} ")
|
||||
return this;
|
||||
return this
|
||||
}
|
||||
originLonLatPoint = lonLatPoint
|
||||
if (isGps) {
|
||||
@@ -593,15 +585,15 @@ class MarkerOptions {
|
||||
return originLonLatPoint
|
||||
}
|
||||
|
||||
fun getTitle(): String? {
|
||||
fun getTitle(): String {
|
||||
return this.title
|
||||
}
|
||||
|
||||
fun getText(): String? {
|
||||
fun getText(): String {
|
||||
return this.title
|
||||
}
|
||||
|
||||
fun getSnippet(): String? {
|
||||
fun getSnippet(): String {
|
||||
return this.snippet
|
||||
}
|
||||
|
||||
@@ -632,7 +624,7 @@ class MarkerOptions {
|
||||
}
|
||||
|
||||
fun getMarkerInfoUseCache():Boolean{
|
||||
return markerInfoUseCache;
|
||||
return markerInfoUseCache
|
||||
}
|
||||
|
||||
fun getLonLatPoint(): LonLat? {
|
||||
@@ -645,8 +637,8 @@ class MarkerOptions {
|
||||
// }
|
||||
|
||||
public fun alpha(alpha: Float): MarkerOptions {
|
||||
this.alpha = alpha;
|
||||
return this;
|
||||
this.alpha = alpha
|
||||
return this
|
||||
}
|
||||
|
||||
fun getAlpha(): Float {
|
||||
@@ -658,8 +650,8 @@ class MarkerOptions {
|
||||
}
|
||||
|
||||
fun rotateAngle(rotateAngle: Float): MarkerOptions {
|
||||
this.rotateAngle = rotateAngle;
|
||||
return this;
|
||||
this.rotateAngle = rotateAngle
|
||||
return this
|
||||
}
|
||||
|
||||
//获取Marker覆盖物是否允许InfoWindow显示, 可以通过 Marker.setInfoWindowEnable(boolean) 进行设置
|
||||
@@ -668,8 +660,8 @@ class MarkerOptions {
|
||||
}
|
||||
|
||||
fun infoWindowEnable(enabled: Boolean): MarkerOptions {
|
||||
this.infoWindowEnabled = enabled;
|
||||
return this;
|
||||
this.infoWindowEnabled = enabled
|
||||
return this
|
||||
}
|
||||
|
||||
fun getId(): String {
|
||||
|
||||
@@ -2,15 +2,9 @@ package com.zhidaoauto.map.sdk.open.marker
|
||||
|
||||
|
||||
|
||||
class MarkerRotateAnimation: Animation {
|
||||
private var startAng: Float = 0f
|
||||
private var endAng: Float = 0f
|
||||
class MarkerRotateAnimation(private var startAng: Float, private var endAng: Float) : Animation() {
|
||||
private var duration:Long = 0
|
||||
|
||||
constructor(startAng: Float, endAng: Float){
|
||||
this.startAng = startAng
|
||||
this.endAng = endAng
|
||||
}
|
||||
fun setDuration(duration: Long) {
|
||||
this.duration =duration
|
||||
}
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
package com.zhidaoauto.map.sdk.open.marker
|
||||
|
||||
|
||||
class MarkerScaleAnimation : Animation {
|
||||
var scaleStart: Float = 1.0f
|
||||
var scaleEnd: Float = 0f
|
||||
class MarkerScaleAnimation(var scaleStart: Float, var scaleEnd: Float) : Animation() {
|
||||
private var duration: Long = 0
|
||||
|
||||
constructor(scaleStart: Float, scaleEnd: Float) {
|
||||
this.scaleStart = scaleStart
|
||||
this.scaleEnd = scaleEnd
|
||||
}
|
||||
|
||||
fun setDuration(duration: Long) {
|
||||
this.duration = duration
|
||||
}
|
||||
|
||||
@@ -8,7 +8,12 @@ import com.zhidaoauto.map.sdk.open.tools.MD5Utils
|
||||
import java.util.UUID
|
||||
|
||||
class MultiPointOverlayOptions {
|
||||
var id: String
|
||||
|
||||
companion object {
|
||||
private const val TAG = "MultiPointOverlayOption"
|
||||
}
|
||||
|
||||
var id: String = UUID.randomUUID().toString()
|
||||
var data: List<MarkerOptions> = ArrayList()
|
||||
var markerIconName: String = "111"
|
||||
private var icon = 0
|
||||
@@ -20,11 +25,11 @@ class MultiPointOverlayOptions {
|
||||
val markerBytes = descriptor.getBytes()
|
||||
MD5Utils.getInstanse()
|
||||
this.markerIconName = MD5Utils.getMD5String(markerBytes)
|
||||
if (!(mapController?.getMarkerCall()?.containMarkerIcon(markerIconName)?:true)) {
|
||||
if (mapController.getMarkerCall()?.containMarkerIcon(markerIconName) == false) {
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"markerop--setIcon--addImagetoImageManager:${markerIconName}")
|
||||
}
|
||||
val result = mapController?.addImage(
|
||||
val result = mapController.addImage(
|
||||
this.markerIconName,
|
||||
markerBytes,
|
||||
descriptor.width,
|
||||
@@ -60,11 +65,4 @@ class MultiPointOverlayOptions {
|
||||
'}'
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "MultiPointOverlayOption"
|
||||
}
|
||||
|
||||
init {
|
||||
id = UUID.randomUUID().toString()
|
||||
}
|
||||
}
|
||||
@@ -78,9 +78,9 @@ class NextTurnTipView : ImageView {
|
||||
for ((i,icon) in defaultIconId.withIndex()) {
|
||||
if (icon == nID) {
|
||||
if (customIconTypeDrawables != null && customResources != null)
|
||||
return customIconTypeDrawables!!.get(i)
|
||||
return customIconTypeDrawables!![i]
|
||||
else
|
||||
return defaultIconTypes.get(i)
|
||||
return defaultIconTypes[i]
|
||||
}
|
||||
}
|
||||
return defaultIconTypes[0]
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.view.View
|
||||
import android.widget.ImageView
|
||||
import com.zhidaoauto.map.sdk.open.nav.model.TrafficStatus
|
||||
import java.util.*
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class TmcBarView : View {
|
||||
/**
|
||||
@@ -118,9 +119,9 @@ class TmcBarView : View {
|
||||
var tmcBarLength = mTmcBarItems!!.size - 1
|
||||
//从上往下绘制
|
||||
while (tmcBarLength >= 0) {
|
||||
var trafficStatus = mTmcBarItems!![tmcBarLength]
|
||||
val trafficStatus = mTmcBarItems!![tmcBarLength]
|
||||
////计算tmcBar在绘制过程中每一小段的长度
|
||||
val itemHeight = Math.round(trafficStatus.getLength() * rateDistanceToViewHeight * 100.0f) * 0.01f
|
||||
val itemHeight = (trafficStatus.getLength() * rateDistanceToViewHeight * 100.0f).roundToInt() * 0.01f
|
||||
realDistanceSum += itemHeight
|
||||
getPaintInColor(getColor(trafficStatus.getStatus()))?.let {
|
||||
canvas.drawRect(0.0f, realDistanceSum - itemHeight, width.toFloat(), realDistanceSum, it)
|
||||
|
||||
@@ -20,7 +20,7 @@ object NaviModel {
|
||||
val result = naviRepository.route(lon, lat, targetLon, targetLat, wayPoints)
|
||||
if (result is Result.Success) {
|
||||
val list = ArrayList<LonLatPoint>()
|
||||
result.data?.let {
|
||||
result.data.let {
|
||||
for (ll in it.routeSolution.paths){
|
||||
list.add(LonLatPoint(ll.lon.toDouble()/100000000,ll.lat.toDouble()/100000000))
|
||||
}
|
||||
|
||||
@@ -8,18 +8,17 @@ class NaviRepository: BaseRepository() {
|
||||
|
||||
suspend fun route(lon:Double,lat:Double,targetLon:Double,targetLat:Double, wayPoints: String): Result<NaviResponse> {
|
||||
val map = HashMap<String,String>()
|
||||
map.put("lon","$lon")
|
||||
map.put("lat","$lat")
|
||||
map.put("targetLon","$targetLon")
|
||||
map.put("targetLat","$targetLat")
|
||||
map.put("isVr","1")
|
||||
map.put("barricadeTileId","0")
|
||||
map.put("barricadeLinkId","0")
|
||||
map.put("resultType","0")
|
||||
map.put("wayPoints","")
|
||||
map["lon"] = "$lon"
|
||||
map["lat"] = "$lat"
|
||||
map["targetLon"] = "$targetLon"
|
||||
map["targetLat"] = "$targetLat"
|
||||
map["isVr"] = "1"
|
||||
map["barricadeTileId"] = "0"
|
||||
map["barricadeLinkId"] = "0"
|
||||
map["resultType"] = "0"
|
||||
map["wayPoints"] = ""
|
||||
|
||||
return safeApiCall(
|
||||
|
||||
call = { executeResponse(NavRetrofitClient.service.route(map), {}) },
|
||||
errorMessage = "返回失败!"
|
||||
)
|
||||
|
||||
@@ -75,8 +75,6 @@ object NavRetrofitClient : BaseRetrofitClient() {
|
||||
}
|
||||
|
||||
private fun checkTokenUrl(url: String): Boolean {
|
||||
return if (url.contains("/login")) {
|
||||
false
|
||||
} else true
|
||||
return !url.contains("/login")
|
||||
}
|
||||
}
|
||||
@@ -75,8 +75,6 @@ object WeatherRetrofitClient : BaseRetrofitClient() {
|
||||
}
|
||||
|
||||
private fun checkTokenUrl(url: String): Boolean {
|
||||
return if (url.contains("/login")) {
|
||||
false
|
||||
} else true
|
||||
return !url.contains("/login")
|
||||
}
|
||||
}
|
||||
@@ -3,20 +3,19 @@ package com.zhidaoauto.map.sdk.open.polygon
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController
|
||||
|
||||
class Polygon3D {
|
||||
class Polygon3D(polygon3DOption: Polygon3DOption) {
|
||||
|
||||
private var id: String
|
||||
private var polygon3DOption: Polygon3DOption? = null
|
||||
private var polygon3DOption: Polygon3DOption? = polygon3DOption
|
||||
|
||||
constructor(polygon3DOption: Polygon3DOption){
|
||||
this.polygon3DOption = polygon3DOption
|
||||
init {
|
||||
id = polygon3DOption.id
|
||||
}
|
||||
fun remove(mapController: IMapController?) {
|
||||
mapController?.removePel(id)
|
||||
}
|
||||
|
||||
fun getId(): String? {
|
||||
fun getId(): String {
|
||||
return id
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.zhidaoauto.map.sdk.open.view.MapAutoView
|
||||
|
||||
|
||||
object Polygon3DHelper {
|
||||
private val TAG = javaClass.simpleName
|
||||
|
||||
fun draw3DPolygon(polygon3DOption: Polygon3DOption,mapAutoView: MapAutoView): Polygon3D? {
|
||||
val data = polygon3DOption.getLonLatPoints()
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.zhidaoauto.map.sdk.open.polygon
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
import java.util.UUID
|
||||
|
||||
class Polygon3DOption {
|
||||
class Polygon3DOption() {
|
||||
var id: String
|
||||
private var color = 0
|
||||
private var lineWidth = 0f
|
||||
@@ -16,16 +16,16 @@ class Polygon3DOption {
|
||||
|
||||
private var isGps = false
|
||||
|
||||
constructor(){
|
||||
init {
|
||||
id = UUID.randomUUID().toString()
|
||||
}
|
||||
|
||||
fun setId(id:String): Polygon3DOption? {
|
||||
fun setId(id:String): Polygon3DOption {
|
||||
this.id = id
|
||||
return this
|
||||
}
|
||||
|
||||
fun setColor(color: Int): Polygon3DOption? {
|
||||
fun setColor(color: Int): Polygon3DOption {
|
||||
this.color = color
|
||||
return this
|
||||
}
|
||||
@@ -34,7 +34,6 @@ class Polygon3DOption {
|
||||
return this.color
|
||||
}
|
||||
|
||||
|
||||
fun getLineWidth(): Float {
|
||||
return lineWidth
|
||||
}
|
||||
@@ -44,12 +43,10 @@ class Polygon3DOption {
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
fun getLonLatPoints(): List<LonLatPoint>? {
|
||||
return lonLatPoints
|
||||
}
|
||||
|
||||
|
||||
fun setLonLatPoints(points: List<LonLatPoint>?): Polygon3DOption? {
|
||||
if (points == null || points.isEmpty()) {
|
||||
return this
|
||||
@@ -68,7 +65,6 @@ class Polygon3DOption {
|
||||
return height
|
||||
}
|
||||
|
||||
|
||||
fun setCount(count: Int): Polygon3DOption{
|
||||
this.count = count
|
||||
return this
|
||||
|
||||
@@ -5,34 +5,32 @@ import com.alibaba.fastjson.JSONException
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController
|
||||
|
||||
class Polyline {
|
||||
class Polyline(polylineOptions: PolylineOptions, mapController: IMapController?) {
|
||||
private var id: String = ""
|
||||
private var polylineOptions: PolylineOptions? = null
|
||||
private var polylineOptions: PolylineOptions? = polylineOptions
|
||||
|
||||
private var mMapController:IMapController? = null
|
||||
private var mMapController:IMapController? = mapController
|
||||
|
||||
constructor(polylineOptions: PolylineOptions,mapController: IMapController?) {
|
||||
this.polylineOptions = polylineOptions
|
||||
this.mMapController = mapController
|
||||
init {
|
||||
id = polylineOptions.id
|
||||
}
|
||||
|
||||
fun remove() {
|
||||
// 移除单个线
|
||||
id?.let{
|
||||
id.let{
|
||||
mMapController?.removePel(it)
|
||||
}
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
fun getId(): String? {
|
||||
fun getId(): String {
|
||||
return id
|
||||
}
|
||||
|
||||
fun setGeodesic(draw: Boolean) {
|
||||
if (polylineOptions != null) {
|
||||
polylineOptions?.geodesic(draw)
|
||||
id?.let {
|
||||
id.let {
|
||||
mMapController?.setGeodesic(it, draw)
|
||||
refreshMap()
|
||||
}
|
||||
@@ -47,7 +45,7 @@ class Polyline {
|
||||
fun setDottedLine(dottedLine: Boolean) {
|
||||
if (polylineOptions != null) {
|
||||
polylineOptions?.dottedLine(dottedLine)
|
||||
id?.let{
|
||||
id.let{
|
||||
mMapController?.setDottedLineType(it, 0)
|
||||
refreshMap()
|
||||
}
|
||||
@@ -63,7 +61,7 @@ class Polyline {
|
||||
fun setWidth(width: Float) {
|
||||
if (polylineOptions != null) {
|
||||
polylineOptions?.lineWidth = width
|
||||
id?.let {
|
||||
id.let {
|
||||
mMapController?.setWidth(it, width)
|
||||
refreshMap()
|
||||
}
|
||||
|
||||
@@ -13,7 +13,14 @@ import java.util.UUID
|
||||
|
||||
class PolylineOptions {
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
companion object {
|
||||
private const val TAG = "PolylineOptions"
|
||||
//空隙长
|
||||
const val DOT_LINE_TYPE_SHORT_LINE = 1
|
||||
//实线长
|
||||
const val DOT_LINE_TYPE_LONG_LINE = 2
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
private var mMapController:IMapController? = null
|
||||
var id: String = ""
|
||||
@@ -68,15 +75,6 @@ class PolylineOptions {
|
||||
|
||||
private var isBright = false
|
||||
|
||||
companion object {
|
||||
//空隙长
|
||||
val DOT_LINE_TYPE_SHORT_LINE = 1
|
||||
|
||||
//实线长
|
||||
val DOT_LINE_TYPE_LONG_LINE = 2
|
||||
}
|
||||
|
||||
|
||||
constructor(mapController: IMapController?){
|
||||
this.mMapController = mapController
|
||||
id = UUID.randomUUID().toString()
|
||||
@@ -116,7 +114,7 @@ class PolylineOptions {
|
||||
this.lonLatPoints = lonLatPoints
|
||||
lonLats.clear()
|
||||
var lonLat: LonLat? = null
|
||||
var lastLonlat: LonLat? = null
|
||||
var lastLonLat: LonLat? = null
|
||||
for ((i,lonlatPoint) in lonLatPoints.withIndex()) {
|
||||
if (lonlatPoint == null) {
|
||||
continue
|
||||
@@ -125,20 +123,20 @@ class PolylineOptions {
|
||||
Log.e(TAG, "position is error :${lonlatPoint.longitude},${lonlatPoint.latitude} ")
|
||||
return this;
|
||||
}
|
||||
if(isGps){
|
||||
lonLat = LonLat(lonlatPoint.longitude, lonlatPoint.latitude)
|
||||
lonLat = if(isGps){
|
||||
LonLat(lonlatPoint.longitude, lonlatPoint.latitude)
|
||||
} else{
|
||||
lonLat = getInstance().getLonLatProxy().switchLonLat(lonlatPoint)
|
||||
getInstance().getLonLatProxy().switchLonLat(lonlatPoint)
|
||||
}
|
||||
if(i == 0){
|
||||
lonLats.add(lonLat)
|
||||
lastLonlat = lonLat
|
||||
lastLonLat = lonLat
|
||||
}else{
|
||||
if(lastLonlat?.lat == lonLat.lat && lastLonlat?.lon == lonLat.lon){
|
||||
if(lastLonLat?.lat == lonLat.lat && lastLonLat.lon == lonLat.lon){
|
||||
|
||||
}else{
|
||||
lonLats.add(lonLat)
|
||||
lastLonlat = lonLat
|
||||
lastLonLat = lonLat
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ class AMapViewWrapper(mMapView: MapAutoView) : IMogoMapView, IMogoMapUIControlle
|
||||
//todo 多实例 对象替换
|
||||
override fun onStopLineInfo(stopLine: StopLine?) {
|
||||
val carLoc = getChassisLocationWGS84()
|
||||
if (stopLine != null && !stopLine.road_id.isEmpty() && stopLine.points.size > 0) {
|
||||
if (stopLine != null && stopLine.road_id.isNotEmpty() && stopLine.points.size > 0) {
|
||||
val points = stopLine.points
|
||||
d(SceneConstant.M_MAP + TAG, "onStopLineInfo:stop_line$stopLine")
|
||||
val stopInfo = convert(stopLine)
|
||||
|
||||
Reference in New Issue
Block a user