Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
p x
MapMultiEngine
Commits
1fced44e
Commit
1fced44e
authored
Oct 30, 2025
by
p x
Browse files
不让用户传入mapreadyView
parent
aeb35fb4
Changes
134
Hide whitespace changes
Inline
Side-by-side
mapapi/src/main/java/com/sd/api/location/MineGpsLocation.kt
View file @
1fced44e
...
...
@@ -61,7 +61,7 @@ object MineGpsLocation {
override
fun
onLocationChanged
(
location
:
MineLocation
?)
{
// println("-------四维定位改变 = ${location?.latitude} curLng=${location?.longitude} speed=${location?.speed}")
var
loc
=
MSLocCb
.
Companion
.
instance
.
apply
{
var
loc
=
MSLocCb
.
instance
.
apply
{
lat
=
location
?.
latitude
?:
0.0
lng
=
location
?.
longitude
?:
0.0
speed
=
location
?.
speed
?:
0f
...
...
mapapi/src/main/java/com/sd/api/maps/DelDrawInMap.kt
View file @
1fced44e
...
...
@@ -9,7 +9,7 @@ import com.sd.api.maps.cdata.MSMarker
/**
* 删除地图上的绘制
*/
object
DelDrawInMap
{
object
DelDrawInMap
:
MsOperationParent
()
{
/**
...
...
@@ -71,46 +71,46 @@ object DelDrawInMap {
* @param isDotted 是否为虚线,默认为false
* @return MSOverlay 覆盖物对象
*/
/* fun drawPolyline(
mapReadView: MapReadyView?,
msLatLng: List<MSLatLng>,
width: Float = 10f,
fcolor: Int = "#FF00FF".toColorInt(),
isDotted: Boolean = false
): MSOverlay {
// 根据地图类型绘制不同平台的线
when (MSDKInitializer.getMapType()) {
// 绘制自定义地图的线
MAP_TYPE.MINE -> {
var latLngs = msLatLng.map {
LatLng(it.lat, it.lng)
}
var options = PolylineOptions()
// 添加顶点坐标
.addAll(latLngs)
.width(width)
.color(fcolor)
.setDottedLine(isDotted)
var polyline = mapReadView?.mMineMap?.addPolyline(options)
MSOverlay.polyline = polyline
return MSOverlay
}
/* fun drawPolyline(
mapReadView: MapReadyView?,
msLatLng: List<MSLatLng>,
width: Float = 10f,
fcolor: Int = "#FF00FF".toColorInt(),
isDotted: Boolean = false
): MSOverlay {
// 根据地图类型绘制不同平台的线
when (MSDKInitializer.getMapType()) {
// 绘制自定义地图的线
MAP_TYPE.MINE -> {
var latLngs = msLatLng.map {
LatLng(it.lat, it.lng)
}
var options = PolylineOptions()
// 添加顶点坐标
.addAll(latLngs)
.width(width)
.color(fcolor)
.setDottedLine(isDotted)
var polyline = mapReadView?.mMineMap?.addPolyline(options)
MSOverlay.polyline = polyline
return MSOverlay
}
// 绘制高德地图的线
MAP_TYPE.AMAP -> {
var latLngs = msLatLng.map {
ALatLng(it.lat, it.lng)
}
val aOption = APolylineOptions().addAll(latLngs)
.width(width)
.color(fcolor)
.setDottedLine(isDotted)
var polyline = mapReadView?.aMap?.addPolyline(aOption)
MSOverlay.aPolyline = polyline
return MSOverlay
}
}
}*/
// 绘制高德地图的线
MAP_TYPE.AMAP -> {
var latLngs = msLatLng.map {
ALatLng(it.lat, it.lng)
}
val aOption = APolylineOptions().addAll(latLngs)
.width(width)
.color(fcolor)
.setDottedLine(isDotted)
var polyline = mapReadView?.aMap?.addPolyline(aOption)
MSOverlay.aPolyline = polyline
return MSOverlay
}
}
}*/
/**绘制圆形
...
...
@@ -123,44 +123,44 @@ object DelDrawInMap {
* @param strokeWidth 边框宽度,默认为15f
* @return MSOverlay 返回覆盖物对象
*/
/* fun drawCircle(
mapReadView: MapReadyView?,
lat: Double,
lng: Double,
radius: Float,
fillColor: Int = "#50FF0000".toColorInt(),
strokeColor: Int = "#500000FF".toColorInt(),
strokeWidth: Float = 15f
): MSOverlay {
// 根据地图类型绘制不同类型的圆形
when (MSDKInitializer.getMapType()) {
MAP_TYPE.MINE -> {
var latLng = LatLng(lat, lng)
val options = CircleOptions()
.center(latLng)
.radius(radius)
.fillColor(fillColor)
.strokeColor(strokeColor)
.strokeWidth(strokeWidth)
var circle = mapReadView?.mMineMap?.addCircle(options)
MSOverlay.circle = circle
return MSOverlay
}
/* fun drawCircle(
mapReadView: MapReadyView?,
lat: Double,
lng: Double,
radius: Float,
fillColor: Int = "#50FF0000".toColorInt(),
strokeColor: Int = "#500000FF".toColorInt(),
strokeWidth: Float = 15f
): MSOverlay {
// 根据地图类型绘制不同类型的圆形
when (MSDKInitializer.getMapType()) {
MAP_TYPE.MINE -> {
var latLng = LatLng(lat, lng)
val options = CircleOptions()
.center(latLng)
.radius(radius)
.fillColor(fillColor)
.strokeColor(strokeColor)
.strokeWidth(strokeWidth)
var circle = mapReadView?.mMineMap?.addCircle(options)
MSOverlay.circle = circle
return MSOverlay
}
MAP_TYPE.AMAP -> {
var latLng = ALatLng(lat, lng)
val options = ACircleOptions()
.center(latLng)
.radius(radius.toDouble())
.fillColor(fillColor)
.strokeColor(strokeColor)
.strokeWidth(strokeWidth)
var circle = mapReadView?.aMap?.addCircle(options)
MSOverlay.aCircle = circle
return MSOverlay
}
}
}*/
MAP_TYPE.AMAP -> {
var latLng = ALatLng(lat, lng)
val options = ACircleOptions()
.center(latLng)
.radius(radius.toDouble())
.fillColor(fillColor)
.strokeColor(strokeColor)
.strokeWidth(strokeWidth)
var circle = mapReadView?.aMap?.addCircle(options)
MSOverlay.aCircle = circle
return MSOverlay
}
}
}*/
/***
...
...
@@ -171,48 +171,48 @@ object DelDrawInMap {
* @param strokeWidth 边框宽度
* @param strokeColor 边框颜色
* ****/
/* fun drawPolygon(
mapReadView: MapReadyView?,
msLatLng: List<MSLatLng>,
dLine: Boolean = false,
fillColor: Int = "#10FF00FF".toColorInt(),
strokeWidth: Float = 5f,
strokeColor: Int = "#50FF00FF".toColorInt()
): MSOverlay {
when (MSDKInitializer.getMapType()) {
MAP_TYPE.MINE -> {
var latLngs = msLatLng.map {
LatLng(it.lat, it.lng)
}
// 声明 多边形参数对象
val polygonOptions = PolygonOptions().apply {
addAll(latLngs)
fillColor(fillColor)
strokeWidth(strokeWidth)
strokeColor(strokeColor)
dottedLine(dLine)
}
var polygon = mapReadView?.mMineMap?.addPolygon(polygonOptions)
MSOverlay.polygon = polygon
return MSOverlay
}
/* fun drawPolygon(
mapReadView: MapReadyView?,
msLatLng: List<MSLatLng>,
dLine: Boolean = false,
fillColor: Int = "#10FF00FF".toColorInt(),
strokeWidth: Float = 5f,
strokeColor: Int = "#50FF00FF".toColorInt()
): MSOverlay {
when (MSDKInitializer.getMapType()) {
MAP_TYPE.MINE -> {
var latLngs = msLatLng.map {
LatLng(it.lat, it.lng)
}
// 声明 多边形参数对象
val polygonOptions = PolygonOptions().apply {
addAll(latLngs)
fillColor(fillColor)
strokeWidth(strokeWidth)
strokeColor(strokeColor)
dottedLine(dLine)
}
var polygon = mapReadView?.mMineMap?.addPolygon(polygonOptions)
MSOverlay.polygon = polygon
return MSOverlay
}
MAP_TYPE.AMAP -> {
var latLngs = msLatLng.map {
ALatLng(it.lat, it.lng)
}
val aPolygonOptions = APolygonOptions().apply {
addAll(latLngs)
fillColor(fillColor)
strokeWidth(strokeWidth)
strokeColor(strokeColor)
}
var polygon = mapReadView?.aMap?.addPolygon(aPolygonOptions)
MSOverlay.aPolygon = polygon
return MSOverlay
}
}
}*/
MAP_TYPE.AMAP -> {
var latLngs = msLatLng.map {
ALatLng(it.lat, it.lng)
}
val aPolygonOptions = APolygonOptions().apply {
addAll(latLngs)
fillColor(fillColor)
strokeWidth(strokeWidth)
strokeColor(strokeColor)
}
var polygon = mapReadView?.aMap?.addPolygon(aPolygonOptions)
MSOverlay.aPolygon = polygon
return MSOverlay
}
}
}*/
/**
...
...
@@ -220,10 +220,10 @@ object DelDrawInMap {
* @param mapReadView 地图准备就绪的视图对象,可能为null
* @param mSMarker 要删除的标记点对象,可能为null
*/
fun
deleteMarker
(
mapReadView
:
MapReadyView
?,
mSMarker
:
MSMarker
?)
{
fun
deleteMarker
(
mSMarker
:
MSMarker
?)
{
if
(
mSMarker
==
null
)
return
var
mapReadView
=
getMapReadView
()
// 根据不同的地图类型执行相应的删除操作
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
...
...
@@ -243,12 +243,12 @@ object DelDrawInMap {
/**
* 删除地图上的线
* @param mapReadView 地图准备就绪的视图对象,可能为null
* @param mSOverlay 包含折线信息的覆盖物对象,可能为null
*/
fun
deletePolyline
(
mapReadView
:
MapReadyView
?,
mSOverlay
:
MSOverlay
?)
{
fun
deletePolyline
(
mSOverlay
:
MSOverlay
?)
{
if
(
mSOverlay
==
null
)
return
var
mapReadView
=
getMapReadView
()
// 根据不同的地图类型删除对应的折线
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
...
...
@@ -264,13 +264,13 @@ object DelDrawInMap {
/**
* 删除圆形覆盖物
* @param mapReadView 地图准备视图对象,可能为null
* @param mSOverlay 圆形覆盖物对象,可能为null
*/
fun
deleteCircle
(
mapReadView
:
MapReadyView
?,
mSOverlay
:
MSOverlay
?)
{
fun
deleteCircle
(
mSOverlay
:
MSOverlay
?)
{
if
(
mSOverlay
==
null
)
{
return
}
var
mapReadView
=
getMapReadView
()
// 根据不同的地图类型执行对应的圆形删除操作
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
...
...
@@ -285,13 +285,13 @@ object DelDrawInMap {
/**
* 删除地图上的面
* @param mapReadView 地图准备就绪的视图对象,可能为null
* @param mSOverlay 面覆盖物对象,可能为null
*/
fun
deletePolygon
(
mapReadView
:
MapReadyView
?,
mSOverlay
:
MSOverlay
?)
{
fun
deletePolygon
(
mSOverlay
:
MSOverlay
?)
{
if
(
mSOverlay
==
null
)
{
return
}
var
mapReadView
=
getMapReadView
()
// 根据不同的地图类型执行对应的删除操作
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
...
...
mapapi/src/main/java/com/sd/api/maps/DrawInMap.kt
View file @
1fced44e
...
...
@@ -3,32 +3,71 @@ package com.sd.api.maps
import
androidx.core.graphics.toColorInt
import
com.sd.api.MAP_TYPE
import
com.sd.api.MSDKInitializer
import
com.sd.api.ui.MapReadyView
import
com.sd.api.maps.cdata.MSOverlay
import
com.sd.api.maps.mine.MineDrawInMap
import
com.sd.api.maps.amap.AmapDrawInMap
import
com.sd.api.maps.cdata.MSLatLng
import
com.sd.api.maps.cdata.MSMarker
import
com.sd.api.maps.cdata.MSOverlay
import
com.sd.api.maps.mine.MineDrawInMap
/***绘制线选项**/
class
MsPolylineOptions
{
/***填充颜色**/
var
fcolor
=
"#000000"
.
toColorInt
()
/***描边颜色**/
var
outlineColor
=
"#00000000"
.
toColorInt
()
/***线宽度,默认为10f**/
var
width
=
10f
/***是否为虚线,默认为false**/
var
isDotted
=
false
}
/***绘制圆形选项**/
class
MsCircleOptions
{
/**半径(米)**/
var
radius
=
100f
/***填充颜色,默认为半透明红色*/
var
fillColor
=
"#50FF0000"
.
toColorInt
()
/***边框颜色,默认为半透明蓝色*/
var
strokeColor
=
"#500000FF"
.
toColorInt
()
/*** 边框宽度,默认为15f*/
var
strokeWidth
=
15f
}
class
MsPolygonOptions
{
/***填充颜色**/
var
fillColor
=
"#10FF00FF"
.
toColorInt
()
/***边框颜色**/
var
strokeColor
=
"#500000FF"
.
toColorInt
()
/***边框宽度**/
var
strokeWidth
=
5f
/***是否为虚线,默认为false**/
var
dLine
=
false
}
/**
* 绘制点、线、面
*
* @constructor Create empty Marker pro
*/
object
DrawInMap
{
object
DrawInMap
:
MsOperationParent
()
{
/**
* 绘制 marker 点
* @param mapReadView 地图准备就绪的视图对象
* @param lat 纬度坐标
* @param lng 经度坐标
* @return MSMarker 标记点对象
*/
fun
drawMarket
(
mapReadView
:
MapReadyView
?,
lat
:
Double
,
lng
:
Double
):
MSMarker
{
val
mapReadView
=
getMapReadView
()
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
return
MineDrawInMap
.
drawMarket
(
mapReadView
,
lat
,
lng
)
...
...
@@ -42,87 +81,82 @@ object DrawInMap {
/**
* 绘制线
* @param mapReadView 地图加载返回
* @param msLatLng 坐标点集合
* @param fcolor 线颜色
* @param outlineColor 描边颜色
* @param width 线宽度,默认为10f
* @param isDotted 是否为虚线,默认为false
* @param msPolylineOptions 绘制线选项
* @return MSOverlay 覆盖物对象
*/
fun
drawPolyline
(
mapReadView
:
MapReadyView
?,
msLatLng
:
List
<
MSLatLng
>,
fcolor
:
Int
=
"#000000"
.
toColorInt
(),
outlineColor
:
Int
=
"#00000000"
.
toColorInt
(),
width
:
Float
=
10f
,
isDotted
:
Boolean
=
false
msLatLng
:
List
<
MSLatLng
>,
msPolylineOptions
:
MsPolylineOptions
):
MSOverlay
{
val
mapReadView
=
getMapReadView
()
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
return
MineDrawInMap
.
drawPolyline
(
mapReadView
,
msLatLng
,
fcolor
,
outlineColor
,
width
,
isDotted
)
return
MineDrawInMap
.
drawPolyline
(
mapReadView
,
msLatLng
,
msPolylineOptions
)
}
MAP_TYPE
.
AMAP
->
{
return
AmapDrawInMap
.
drawPolyline
(
mapReadView
,
msLatLng
,
fcolor
,
width
,
isDotted
)
return
AmapDrawInMap
.
drawPolyline
(
mapReadView
,
msLatLng
,
msPolylineOptions
)
}
}
}
/**绘制圆形
* @param mapReadView 地图准备就绪视图对象
* @param lat 维度
* @param lng 经度
* @param radius 半径(米)
* @param fillColor 填充颜色,默认为半透明红色
* @param strokeColor 边框颜色,默认为半透明蓝色
* @param strokeWidth 边框宽度,默认为15f
/**
* 绘制圆形
* @param center 中心点坐标
* @param msCircleOptions 绘制圆形选项
* @return MSOverlay 返回覆盖物对象
*/
fun
drawCircle
(
mapReadView
:
MapReadyView
?,
lat
:
Double
,
lng
:
Double
,
radius
:
Float
,
fillColor
:
Int
=
"#50FF0000"
.
toColorInt
(),
strokeColor
:
Int
=
"#00000000"
.
toColorInt
(),
strokeWidth
:
Float
=
15f
):
MSOverlay
{
center
:
MSLatLng
,
msCircleOptions
:
MsCircleOptions
?
):
MSOverlay
{
val
mapReadView
=
getMapReadView
()
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
return
MineDrawInMap
.
drawCircle
(
mapReadView
,
lat
,
lng
,
radius
,
fillColor
,
strokeColor
,
strokeWidth
)
return
MineDrawInMap
.
drawCircle
(
mapReadView
,
center
,
msCircleOptions
)
}
MAP_TYPE
.
AMAP
->
{
return
AmapDrawInMap
.
drawCircle
(
mapReadView
,
lat
,
lng
,
radius
,
fillColor
,
strokeColor
,
strokeWidth
)
return
AmapDrawInMap
.
drawCircle
(
mapReadView
,
center
,
msCircleOptions
)
}
}
}
/**
*
/**
* 绘制多边形
* @param msLatLng 添加多边形顶点坐标集合
* @param dLine 是否虚线
* @param fillColor 填充颜色
* @param strokeWidth 边框宽度
* @param strokeColor 边框颜色
* ****/
* @param msPolygonOptions 多边形绘制选型
*/
fun
drawPolygon
(
mapReadView
:
MapReadyView
?,
msLatLng
:
List
<
MSLatLng
>,
dLine
:
Boolean
=
false
,
fillColor
:
Int
=
"#10FF00FF"
.
toColorInt
(),
strokeWidth
:
Float
=
5f
,
strokeColor
:
Int
=
"#50FF00FF"
.
toColorInt
()
):
MSOverlay
{
msPolygonOptions
:
MsPolygonOptions
):
MSOverlay
{
val
mapReadView
=
getMapReadView
()
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
return
MineDrawInMap
.
drawPolygon
(
mapReadView
,
msLatLng
,
dLine
,
fillColor
,
strokeWidth
,
strokeColor
)
return
MineDrawInMap
.
drawPolygon
(
mapReadView
,
msLatLng
,
msPolygonOptions
)
}
MAP_TYPE
.
AMAP
->
{
return
AmapDrawInMap
.
drawPolygon
(
mapReadView
,
msLatLng
,
dLine
,
fillColor
,
strokeWidth
,
strokeColor
)
return
AmapDrawInMap
.
drawPolygon
(
mapReadView
,
msLatLng
,
msPolygonOptions
)
}
}
}
...
...
mapapi/src/main/java/com/sd/api/maps/Gestures.kt
View file @
1fced44e
...
...
@@ -2,6 +2,7 @@ package com.sd.api.maps
import
com.sd.api.MAP_TYPE
import
com.sd.api.MSDKInitializer
import
com.sd.api.UserCtx
import
com.sd.api.ui.MapReadyView
import
com.sd.api.maps.amap.AmapGestures
import
com.sd.api.maps.mine.MineGestures
...
...
@@ -9,14 +10,15 @@ import com.sd.api.maps.mine.MineGestures
/**
* 手势控制
*/
object
Gestures
{
object
Gestures
:
MsOperationParent
()
{
/**
* 设置地图旋转手势是否可用
* @param mapReadView 地图准备就绪视图对象
* @param enable 是否启用旋转手势功能
*/
fun
setRotateGesturesEnabled
(
mapReadView
:
MapReadyView
?,
enable
:
Boolean
){
fun
setRotateGesturesEnabled
(
enable
:
Boolean
){
var
mapReadView
=
getMapReadView
()
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MineGestures
.
setRotateGesturesEnabled
(
mapReadView
,
enable
)
...
...
@@ -34,7 +36,8 @@ object Gestures{
* @param mapReadView 地图准备就绪视图对象
* @param enable 是否启用倾斜手势功能,true为启用,false为禁用
* */
fun
setTiltGesturesEnabled
(
mapReadView
:
MapReadyView
?,
enable
:
Boolean
){
fun
setTiltGesturesEnabled
(
enable
:
Boolean
){
var
mapReadView
=
getMapReadView
()
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MineGestures
.
setTiltGesturesEnabled
(
mapReadView
,
enable
)
...
...
mapapi/src/main/java/com/sd/api/maps/Layer.kt
View file @
1fced44e
...
...
@@ -2,21 +2,21 @@ package com.sd.api.maps
import
com.sd.api.MAP_TYPE
import
com.sd.api.MSDKInitializer
import
com.sd.api.ui.MapReadyView
import
com.sd.api.maps.amap.AmapLayers
import
com.sd.api.maps.mine.MineLayers
/**
* 图层操作
*/
object
Layer
{
object
Layer
:
MsOperationParent
()
{
/**
* 切换地图图层
* @param mapReadView 地图准备就绪视图对象
* @param type 1=普通 2=卫星
*/
fun
toggleLayers
(
mapReadView
:
MapReadyView
?,
type
:
Int
)
{
fun
toggleLayers
(
type
:
Int
)
{
var
mapReadView
=
getMapReadView
()
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MineLayers
.
toggleLayers
(
mapReadView
,
type
)
...
...
mapapi/src/main/java/com/sd/api/maps/MSCalcuMapUtil.kt
View file @
1fced44e
...
...
@@ -6,6 +6,9 @@ import com.amap.api.maps.model.LatLng
import
com.sd.api.MAP_TYPE
import
com.sd.api.MSDKInitializer
import
com.sd.api.maps.cdata.MSLatLng
import
kotlin.math.atan2
import
kotlin.math.cos
import
kotlin.math.sin
/**
* 地图计算工具
...
...
@@ -73,4 +76,46 @@ object MSCalcuMapUtil {
}
}
/**
* 根据两个坐标点计算航向角
* @param fromPoint 起始点
* @param toPoint 终点
* @return 航向角(度),范围 0-360
*/
fun
calculateBearing
(
fromPoint
:
MSLatLng
,
toPoint
:
MSLatLng
):
Double
{
return
calculateBearing
(
fromPoint
.
lng
,
fromPoint
.
lat
,
toPoint
.
lng
,
toPoint
.
lat
)
}
/**
* 根据两个坐标点计算航向角
* @param fromLon 起始点经度
* @param fromLat 起始点纬度
* @param toLon 终点经度
* @param toLat 终点纬度
* @return 航向角(度),范围 0-360
*/
private
fun
calculateBearing
(
fromLon
:
Double
,
fromLat
:
Double
,
toLon
:
Double
,
toLat
:
Double
):
Double
{
// 将度转换为弧度
val
lat1
=
Math
.
toRadians
(
fromLat
)
val
lat2
=
Math
.
toRadians
(
toLat
)
val
deltaLon
=
Math
.
toRadians
(
toLon
-
fromLon
)
// 计算航向角
val
y
=
sin
(
deltaLon
)
*
cos
(
lat2
)
val
x
=
cos
(
lat1
)
*
sin
(
lat2
)
-
sin
(
lat1
)
*
cos
(
lat2
)
*
cos
(
deltaLon
)
val
bearing
=
Math
.
toDegrees
(
atan2
(
y
,
x
))
// 确保航向角在 0-360 度范围内
return
(
bearing
+
360
)
%
360
}
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/maps/MSNavi.kt
View file @
1fced44e
...
...
@@ -2,6 +2,7 @@ package com.sd.api.maps
import
com.sd.api.MAP_TYPE
import
com.sd.api.MSDKInitializer
import
com.sd.api.bean.DriverRouteBean
import
com.sd.api.bean.WayPoi
import
com.sd.api.intfaces.OnNaviPresenterListener
import
com.sd.api.maps.amap.AmapNai
...
...
@@ -10,12 +11,22 @@ import com.sd.api.maps.mine.MineNai
import
com.sd.api.ui.MapReadyView
/**
* 导航
*
* @constructor Create empty M s navi
* 导航相关
*/
object
MSNavi
{
fun
init
()
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MineNai
.
init
()
}
MAP_TYPE
.
AMAP
->
{
// AmapNai.init()
}
}
}
/**
* 开始导航
* @param nType 1=自己实现回调 2=直接调用导航组件
...
...
@@ -53,4 +64,40 @@ object MSNavi {
}
}
}
fun
startSimNavi
(
mapReadView
:
MapReadyView
?,
starPoint
:
MSLatLng
,
driverRouteBean
:
DriverRouteBean
?,
onNaviPresenterListener
:
OnNaviPresenterListener
?
)
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MineNai
.
startSimNavi
(
mapReadView
,
starPoint
,
driverRouteBean
?.
routeBase
,
onNaviPresenterListener
)
}
MAP_TYPE
.
AMAP
->
{
}
}
}
fun
addNaviListener
(
listener
:
OnNaviPresenterListener
)
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MineNai
.
addNaviListener
(
listener
)
}
MAP_TYPE
.
AMAP
->
{
}
}
}
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/maps/MSRoutePlans.kt
View file @
1fced44e
...
...
@@ -7,11 +7,10 @@ import com.sd.api.maps.amap.AmapRoutePlans
import
com.sd.api.maps.cdata.MSLatLng
import
com.sd.api.maps.inters.OnDriveRoute
import
com.sd.api.maps.mine.MineRoutePlans
import
com.sd.api.ui.MapReadyView
/**路劲规划 **/
object
MSRoutePlans
{
object
MSRoutePlans
:
MsOperationParent
()
{
/**驾车路径规划
* @param starPoint 起点坐标
...
...
@@ -28,9 +27,9 @@ object MSRoutePlans {
endPoint
:
MSLatLng
,
endName
:
String
=
""
,
ways
:
List
<
WayPoi
>,
mapReadView
:
MapReadyView
?,
onDriveRoute
:
OnDriveRoute
?
)
{
var
mapReadView
=
getMapReadView
()
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MineRoutePlans
.
drivingPathPlanning
(
...
...
mapapi/src/main/java/com/sd/api/maps/MethodAdv.kt
View file @
1fced44e
...
...
@@ -11,7 +11,7 @@ import com.sd.api.maps.mine.MineMethodAdv
*
* @constructor Create empty Method adv pro
*/
object
MethodAdv
{
object
MethodAdv
:
MsOperationParent
()
{
/**
* 改变地图中心点
...
...
@@ -20,10 +20,10 @@ object MethodAdv {
* @param lng 经度
* **/
fun
setMapCenter
(
mapReadView
:
MapReadyView
?,
lat
:
Double
,
lng
:
Double
){
var
mapReadView
=
getMapReadView
()
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MineMethodAdv
.
setMapCenter
(
mapReadView
,
lat
,
lng
)
...
...
@@ -41,7 +41,8 @@ object MethodAdv {
* @param mapReadView 地图准备就绪的视图对象
* @param zoom 缩放级别,值越小站得越高,默认值为11f
* */
fun
setMapZoom
(
mapReadView
:
MapReadyView
?,
zoom
:
Float
=
11f
){
fun
setMapZoom
(
zoom
:
Float
=
11f
){
var
mapReadView
=
getMapReadView
()
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
MineMethodAdv
.
setMapZoom
(
mapReadView
,
zoom
)
...
...
mapapi/src/main/java/com/sd/api/maps/MsOperationParent.kt
0 → 100644
View file @
1fced44e
package
com.sd.api.maps
import
com.sd.api.UserCtx
import
com.sd.api.ui.MapReadyView
import
com.sd.api.utils.ToastHelper
//地图操作父类
open
class
MsOperationParent
{
fun
getMapReadView
():
MapReadyView
?
{
if
(
UserCtx
.
instance
.
mContext
==
null
)
{
return
null
}
if
(
UserCtx
.
instance
.
mapReadyView
==
null
)
{
ToastHelper
.
showShort
(
UserCtx
.
instance
.
mContext
!!
,
"请onMapReady回调完成"
)
return
null
}
return
UserCtx
.
instance
.
mapReadyView
}
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/maps/WmsLayer.kt
0 → 100644
View file @
1fced44e
package
com.sd.api.maps
import
com.amap.api.maps.model.TileOverlay
import
com.amap.api.maps.model.TileOverlayOptions
import
com.sd.api.MAP_TYPE
import
com.sd.api.MSDKInitializer
import
com.sd.api.location.MineGpsLocation
import
com.sd.api.maps.amap.AmapGpsLocation
import
com.sd.api.maps.amap.HeritageScopeTileProvider
import
com.sd.api.ui.MapReadyView
/**
* 加载Wms地图
*/
object
WmsLayer
:
MsOperationParent
()
{
private
var
wmsOverlay
:
TileOverlay
?
=
null
/**
* Load wms layer
* @param url wms地址
*/
fun
loadWmsLayer
(
url
:
String
)
{
var
mapReadView
=
getMapReadView
()
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
}
MAP_TYPE
.
AMAP
->
{
val
tileProvider
=
HeritageScopeTileProvider
(
url
)
var
aMap
=
mapReadView
?.
aMap
wmsOverlay
=
aMap
?.
addTileOverlay
(
TileOverlayOptions
().
tileProvider
(
tileProvider
).
zIndex
(
1f
))
}
}
}
fun
removeWmsLayer
()
{
wmsOverlay
?.
remove
()
}
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/maps/amap/AmapDrawInMap.kt
View file @
1fced44e
...
...
@@ -10,6 +10,9 @@ import com.amap.api.maps.model.PolygonOptions
import
com.amap.api.maps.model.PolylineOptions
import
com.sd.api.R
import
com.sd.api.UserCtx
import
com.sd.api.maps.MsCircleOptions
import
com.sd.api.maps.MsPolygonOptions
import
com.sd.api.maps.MsPolylineOptions
import
com.sd.api.maps.cdata.MSLatLng
import
com.sd.api.ui.MapReadyView
import
com.sd.api.maps.cdata.MSOverlay
...
...
@@ -56,26 +59,22 @@ object AmapDrawInMap {
* 绘制线
* @param mapReadView 地图加载返回
* @param msLatLng 坐标点集合
* @param width 线宽度,默认为10f
* @param fcolor 线颜色,默认为"#FF00FF"对应的int值
* @param isDotted 是否为虚线,默认为false
* @param msPolylineOptions 绘制线选项
* @return MSOverlay 覆盖物对象
*/
fun
drawPolyline
(
mapReadView
:
MapReadyView
?,
msLatLng
:
List
<
MSLatLng
>,
fcolor
:
Int
,
width
:
Float
,
isDotted
:
Boolean
=
false
msPolylineOptions
:
MsPolylineOptions
):
MSOverlay
{
// 绘制高德地图的线
var
latLngs
=
msLatLng
.
map
{
LatLng
(
it
.
lat
,
it
.
lng
)
}
val
aOption
=
PolylineOptions
().
addAll
(
latLngs
)
.
width
(
width
)
.
color
(
fcolor
)
.
setDottedLine
(
isDotted
)
.
width
(
msPolylineOptions
.
width
)
.
color
(
msPolylineOptions
.
fcolor
)
.
setDottedLine
(
msPolylineOptions
.
isDotted
)
var
polyline
=
mapReadView
?.
aMap
?.
addPolyline
(
aOption
)
MSOverlay
.
aPolyline
=
polyline
return
MSOverlay
...
...
@@ -84,65 +83,50 @@ object AmapDrawInMap {
/**绘制圆形
* @param mapReadView 地图准备就绪视图对象
* @param lat 维度
* @param lng 经度
* @param radius 半径(米)
* @param fillColor 填充颜色,默认为半透明红色
* @param strokeColor 边框颜色,默认为半透明蓝色
* @param strokeWidth 边框宽度,默认为15f
* @param center 中心点坐标
* @param msCircleOptions 绘制圆形选项
* @return MSOverlay 返回覆盖物对象
*/
fun
drawCircle
(
mapReadView
:
MapReadyView
?,
lat
:
Double
,
lng
:
Double
,
radius
:
Float
,
fillColor
:
Int
=
"#50FF0000"
.
toColorInt
(),
strokeColor
:
Int
=
"#500000FF"
.
toColorInt
(),
strokeWidth
:
Float
=
15f
center
:
MSLatLng
,
msCircleOptions
:
MsCircleOptions
?
):
MSOverlay
{
var
latLng
=
LatLng
(
lat
,
lng
)
var
latLng
=
LatLng
(
center
.
lat
,
center
.
lng
)
val
options
=
CircleOptions
()
.
center
(
latLng
)
.
radius
(
radius
.
toDouble
())
.
fillColor
(
fillColor
)
.
strokeColor
(
strokeColor
)
.
strokeWidth
(
strokeWidth
)
.
radius
(
msCircleOptions
?.
radius
?
.
toDouble
()
?:
100.0
)
.
fillColor
(
msCircleOptions
?.
fillColor
?:
"#50FF0000"
.
toColorInt
()
)
.
strokeColor
(
msCircleOptions
?.
strokeColor
?:
"#500000FF"
.
toColorInt
()
)
.
strokeWidth
(
msCircleOptions
?.
strokeWidth
?:
15f
)
var
circle
=
mapReadView
?.
aMap
?.
addCircle
(
options
)
MSOverlay
.
aCircle
=
circle
return
MSOverlay
}
/**
*
/**
* 绘制多边形
* @param msLatLng 添加多边形顶点坐标集合
* @param dLine 是否虚线
* @param fillColor 填充颜色
* @param strokeWidth 边框宽度
* @param strokeColor 边框颜色
* ****/
* @param msPolygonOptions 多边形绘制选型
*/
fun
drawPolygon
(
mapReadView
:
MapReadyView
?,
msLatLng
:
List
<
MSLatLng
>,
dLine
:
Boolean
=
false
,
fillColor
:
Int
=
"#10FF00FF"
.
toColorInt
(),
strokeWidth
:
Float
=
5f
,
strokeColor
:
Int
=
"#50FF00FF"
.
toColorInt
()
msPolygonOptions
:
MsPolygonOptions
):
MSOverlay
{
var
latLngs
=
msLatLng
.
map
{
LatLng
(
it
.
lat
,
it
.
lng
)
}
val
aPolygonOptions
=
PolygonOptions
().
apply
{
addAll
(
latLngs
)
fillColor
(
fillColor
)
strokeWidth
(
strokeWidth
)
strokeColor
(
strokeColor
)
fillColor
(
msPolygonOptions
.
fillColor
)
strokeWidth
(
msPolygonOptions
.
strokeWidth
)
strokeColor
(
msPolygonOptions
.
strokeColor
)
}
var
polygon
=
mapReadView
?.
aMap
?.
addPolygon
(
aPolygonOptions
)
MSOverlay
.
aPolygon
=
polygon
return
MSOverlay
}
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/maps/amap/AmapGpsLocation.kt
View file @
1fced44e
...
...
@@ -82,7 +82,7 @@ class AmapGpsLocation {
//errCode等于0代表定位成功,其他的为定位失败,具体的可以参照官网定位错误码说明
if
(
location
.
getErrorCode
()
==
0
)
{
// println("-------高德定位改变 = ${location?.latitude} curLng=${location?.longitude} speed=${location?.speed}")
var
loc
=
MSLocCb
.
Companion
.
instance
.
apply
{
var
loc
=
MSLocCb
.
instance
.
apply
{
lat
=
location
?.
latitude
?:
0.0
lng
=
location
?.
longitude
?:
0.0
speed
=
location
?.
speed
?:
0f
...
...
mapapi/src/main/java/com/sd/api/maps/amap/AmapLocationStyle.kt
View file @
1fced44e
package
com.sd.api.maps.amap
import
com.amap.api.maps.model.MyLocationStyle
import
com.sd.api.ui.MapReadyView
import
com.sd.api.maps.MSLocStyle
import
com.sd.api.ui.MapReadyView
/**
* 显示定位小圆点
...
...
@@ -29,7 +29,10 @@ internal object AmapLocationStyle {
* @param mapReadView 地图准备就绪视图对象
* @param type 定位类型,默认为LOCATION_TYPE_LOCATION_ROTATE,表示连续定位并旋转视角
*/
fun
setLocationStyle
(
mapReadView
:
MapReadyView
?,
type
:
Int
=
MSLocStyle
.
LOCATION_TYPE_LOCATION_ROTATE
)
{
fun
setLocationStyle
(
mapReadView
:
MapReadyView
?,
type
:
Int
=
MSLocStyle
.
LOCATION_TYPE_LOCATION_ROTATE
)
{
var
aMap
=
mapReadView
?.
aMap
aMyLocationStyle
.
myLocationType
(
styleAMap
.
get
(
type
)
!!
)
aMyLocationStyle
.
interval
(
2000
)
//设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。
...
...
mapapi/src/main/java/com/sd/api/maps/amap/HeritageScopeTileProvider.java
0 → 100644
View file @
1fced44e
package
com.sd.api.maps.amap
;
import
com.amap.api.maps.model.UrlTileProvider
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
public
class
HeritageScopeTileProvider
extends
UrlTileProvider
{
private
String
mRootUrl
;
private
static
int
titleSize
=
256
;
private
final
double
initialResolution
=
156543.03392804062
;
private
final
double
originShift
=
20037508.342789244
;
public
HeritageScopeTileProvider
(
String
url
)
{
super
(
titleSize
,
titleSize
);
mRootUrl
=
url
+
"&service=WMS&transparent=true&&version=1.1.0&tiled=true&request=GetMap&srs=EPSG:3857&format=image/png&bbox="
;
// mRootUrl = "http://192.168.59.216:8080/smartmap/wms?service=WMS&transparent=true&&version=1.1.0&tiled=true&request=GetMap&layers=yizhuang:yizhuang_avp&srs=EPSG:3857&format=image/png&bbox=";
// mRootUrl = "http://192.168.59.216:8080/tiles/{z}/{x}/{y}.png?layer=yizhuang:yizhuang_avp&service=WMS&transparent=true&&version=1.1.0&tiled=true&request=GetMap&srs=EPSG:3857&format=image/png&bbox=";
}
@Override
public
URL
getTileUrl
(
int
x
,
int
y
,
int
level
)
{
try
{
// System.out.println("-----------x = " + x + " y = " + y + " level = " + level);
String
url
=
mRootUrl
+
TitleBounds2
(
x
,
y
,
level
);
// System.out.println("-----------url = " + url);
return
new
URL
(
url
);
}
catch
(
MalformedURLException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
private
String
TitleBounds
(
int
tx
,
int
ty
,
int
zoom
)
{
double
minX
=
Pixels2Meters
(
tx
*
titleSize
,
zoom
);
double
maxY
=
-
Pixels2Meters
(
ty
*
titleSize
,
zoom
);
double
maxX
=
Pixels2Meters
((
tx
+
1
)
*
titleSize
,
zoom
);
double
minY
=
-
Pixels2Meters
((
ty
+
1
)
*
titleSize
,
zoom
);
minX
=
Meters2Lon
(
minX
);
minY
=
Meters2Lat
(
minY
);
maxX
=
Meters2Lon
(
maxX
);
maxY
=
Meters2Lat
(
maxY
);
return
minX
+
","
+
Double
.
toString
(
minY
)
+
","
+
Double
.
toString
(
maxX
)
+
","
+
Double
.
toString
(
maxY
)
+
"&width=256&height=256"
;
}
private
double
Pixels2Meters
(
int
p
,
int
zoom
)
{
return
p
*
Resolution
(
zoom
)
-
originShift
;
}
private
double
Resolution
(
int
zoom
)
{
return
initialResolution
/
(
Math
.
pow
(
2
,
zoom
));
}
private
double
Meters2Lon
(
double
mx
)
{
double
lon
=
mx
*
(
180.0
/
originShift
);
return
lon
;
}
private
double
Meters2Lat
(
double
my
)
{
double
lat
=
Math
.
atan
(
Math
.
sinh
(
my
/
originShift
))
*
(
180.0
/
Math
.
PI
);
return
lat
;
}
private
String
TitleBounds2
(
int
tx
,
int
ty
,
int
zoom
)
{
double
max_tile
=
Math
.
pow
(
2
,
zoom
);
// 当前z级的最大瓦片索引(从0开始)
if
(
tx
<
0
||
tx
>=
max_tile
||
ty
<
0
||
ty
>=
max_tile
)
{
System
.
out
.
println
(
"-----------瓦片索引超出范围 = "
);
return
""
;
}
// -- 3. 计算EPSG:3857的bbox
double
resolution
=
EPSG3857
.
size
/
max_tile
;
//-- 单个瓦片的宽度(米)
double
minx
=
EPSG3857
.
origin
+
tx
*
resolution
;
// 左边界
double
maxy
=
EPSG3857
.
max
-
ty
*
resolution
;
//-- 上边界
double
maxx
=
minx
+
resolution
;
// -- 右边界
double
miny
=
maxy
-
resolution
;
//-- 下边界
return
minx
+
","
+
miny
+
","
+
maxx
+
","
+
maxy
+
"&width=256&height=256"
;
}
private
static
class
EPSG3857
{
static
double
origin
=
-
20037508.342789244
;
// 最小x和最小y
static
double
max
=
20037508.342789244
;
// 最大x和最大y
static
double
size
=
40075016.68557849
;
// 直径(2×max)
}
}
mapapi/src/main/java/com/sd/api/maps/mine/MineDrawInMap.kt
View file @
1fced44e
...
...
@@ -9,6 +9,9 @@ import com.minedata.minenavi.map.PolylineOptions
import
com.minedata.minenavi.mapdal.LatLng
import
com.sd.api.R
import
com.sd.api.UserCtx
import
com.sd.api.maps.MsCircleOptions
import
com.sd.api.maps.MsPolygonOptions
import
com.sd.api.maps.MsPolylineOptions
import
com.sd.api.maps.cdata.MSLatLng
import
com.sd.api.maps.cdata.MSMarker
import
com.sd.api.maps.cdata.MSOverlay
...
...
@@ -17,7 +20,7 @@ import com.sd.api.ui.MapReadyView
/**
* 四维在地图上绘制
*/
object
MineDrawInMap
{
internal
object
MineDrawInMap
{
/**
...
...
@@ -50,19 +53,12 @@ object MineDrawInMap {
* 绘制线
* @param mapReadView 地图加载返回
* @param msLatLng 坐标点集合
* @param width 线宽度,默认为10f
* @param fcolor 线颜色,默认为"#FF00FF"对应的int值
* @param outlineColor
* @param isDotted 是否为虚线,默认为false
* @return MSOverlay 覆盖物对象
* @param msPolylineOptions 绘制线选项
*/
fun
drawPolyline
(
mapReadView
:
MapReadyView
?,
msLatLng
:
List
<
MSLatLng
>,
fcolor
:
Int
,
outlineColor
:
Int
,
width
:
Float
,
isDotted
:
Boolean
=
false
msPolylineOptions
:
MsPolylineOptions
):
MSOverlay
{
// 绘制自定义地图的线
var
latLngs
=
msLatLng
.
map
{
...
...
@@ -71,10 +67,10 @@ object MineDrawInMap {
var
options
=
PolylineOptions
()
// 添加顶点坐标
.
addAll
(
latLngs
)
.
width
(
width
)
.
color
(
fcolor
)
.
outlineColor
(
outlineColor
)
.
setDottedLine
(
isDotted
)
.
width
(
msPolylineOptions
.
width
)
.
color
(
msPolylineOptions
.
fcolor
)
.
outlineColor
(
msPolylineOptions
.
outlineColor
)
.
setDottedLine
(
msPolylineOptions
.
isDotted
)
var
polyline
=
mapReadView
?.
mMineMap
?.
addPolyline
(
options
)
MSOverlay
.
polyline
=
polyline
return
MSOverlay
...
...
@@ -83,52 +79,38 @@ object MineDrawInMap {
/**绘制圆形
* @param mapReadView 地图准备就绪视图对象
* @param lat 维度
* @param lng 经度
* @param radius 半径(米)
* @param fillColor 填充颜色,默认为半透明红色
* @param strokeColor 边框颜色,默认为半透明蓝色
* @param strokeWidth 边框宽度,默认为15f
* @param center 中心点坐标
* @param msCircleOptions 绘制圆形选项
* @return MSOverlay 返回覆盖物对象
*/
fun
drawCircle
(
mapReadView
:
MapReadyView
?,
lat
:
Double
,
lng
:
Double
,
radius
:
Float
,
fillColor
:
Int
=
"#50FF0000"
.
toColorInt
(),
strokeColor
:
Int
=
"#500000FF"
.
toColorInt
(),
strokeWidth
:
Float
=
15f
center
:
MSLatLng
,
msCircleOptions
:
MsCircleOptions
?
):
MSOverlay
{
// 根据地图类型绘制不同类型的圆形
var
latLng
=
LatLng
(
lat
,
lng
)
var
latLng
=
LatLng
(
center
.
lat
,
center
.
lng
)
val
options
=
CircleOptions
()
.
center
(
latLng
)
.
radius
(
radius
)
.
fillColor
(
fillColor
)
.
strokeColor
(
strokeColor
)
.
strokeWidth
(
strokeWidth
)
.
radius
(
msCircleOptions
?.
radius
?:
100f
)
.
fillColor
(
msCircleOptions
?.
fillColor
?:
"#50FF0000"
.
toColorInt
()
)
.
strokeColor
(
msCircleOptions
?.
strokeColor
?:
"#500000FF"
.
toColorInt
()
)
.
strokeWidth
(
msCircleOptions
?.
strokeWidth
?:
15f
)
var
circle
=
mapReadView
?.
mMineMap
?.
addCircle
(
options
)
MSOverlay
.
circle
=
circle
return
MSOverlay
}
/**
*
/**
* 绘制多边形
* @param msLatLng 添加多边形顶点坐标集合
* @param dLine 是否虚线
* @param fillColor 填充颜色
* @param strokeWidth 边框宽度
* @param strokeColor 边框颜色
* ****/
* @param msPolygonOptions 多边形绘制选型
*/
fun
drawPolygon
(
mapReadView
:
MapReadyView
?,
msLatLng
:
List
<
MSLatLng
>,
dLine
:
Boolean
=
false
,
fillColor
:
Int
=
"#10FF00FF"
.
toColorInt
(),
strokeWidth
:
Float
=
5f
,
strokeColor
:
Int
=
"#50FF00FF"
.
toColorInt
()
msPolygonOptions
:
MsPolygonOptions
):
MSOverlay
{
var
latLngs
=
msLatLng
.
map
{
LatLng
(
it
.
lat
,
it
.
lng
)
...
...
@@ -136,10 +118,10 @@ object MineDrawInMap {
// 声明 多边形参数对象
val
polygonOptions
=
PolygonOptions
().
apply
{
addAll
(
latLngs
)
fillColor
(
fillColor
)
strokeWidth
(
strokeWidth
)
strokeColor
(
strokeColor
)
dottedLine
(
dLine
)
fillColor
(
msPolygonOptions
.
fillColor
)
strokeWidth
(
msPolygonOptions
.
strokeWidth
)
strokeColor
(
msPolygonOptions
.
strokeColor
)
dottedLine
(
msPolygonOptions
.
dLine
)
}
var
polygon
=
mapReadView
?.
mMineMap
?.
addPolygon
(
polygonOptions
)
MSOverlay
.
polygon
=
polygon
...
...
mapapi/src/main/java/com/sd/api/maps/mine/MineNai.kt
View file @
1fced44e
...
...
@@ -17,10 +17,10 @@ import com.minedata.minenavi.navi.RouteBase
import
com.minedata.minenavi.navi.RouteExplorer
import
com.minedata.minenavi.navi.SmoothNaviData
import
com.minedata.minenavi.navi.TmcSections
import
com.minedata.minenavi.tts.NaviSpeaker
import
com.minedata.minenavi.util.Tools
import
com.sd.api.UserCtx
import
com.sd.api.bean.WayPoi
import
com.sd.api.maps.mine.MineNaiParams
import
com.sd.api.intfaces.MyMineNaviListener
import
com.sd.api.intfaces.OnNaviPresenterListener
import
com.sd.api.maps.cdata.MSLatLng
...
...
@@ -39,10 +39,16 @@ object MineNai {
var
mMapCar
:
Model
?
=
null
private
var
mMineMap
:
MineMap
?
=
null
// var onNaviPresenterListener: OnNaviPresenterListener? = null
/**四维导航监听回调***/
var
onNaviPresenterListener
:
OnNaviPresenterListener
?
=
null
private
var
mOnNaviListeners
=
mutableListOf
<
OnNaviPresenterListener
?>()
fun
addNaviListener
(
listener
:
OnNaviPresenterListener
?)
{
mOnNaviListeners
.
add
(
listener
)
}
init
{
fun
init
()
{
mNaviSession
=
NaviSession
.
getInstance
()
mNaviSession
?.
enableSound
(
true
)
var
naviSessionParams
=
NaviSessionParams
().
apply
{
...
...
@@ -53,22 +59,42 @@ object MineNai {
var
context
=
UserCtx
.
Companion
.
instance
.
mContext
mNaviSession
!!
.
init
(
context
,
naviSessionParams
)
mNaviSession
?.
setDataPreference
(
DataPreference
.
preferOnline
)
mNaviSession
?.
addMineNaviListener
(
myMineNaviListener
)
}
/**
* 开启四维导航 客户端自实现数据回调
*/
fun
startNavi
(
mapReadView
:
MapReadyView
?,
onNaviPresenterListener
:
OnNaviPresenterListener
?)
{
mNaviSession
?.
addMineNaviListener
(
myMineNaviListener
)
var
mRouteBas
=
MineRoutePlans
.
mRouteBase
if
(
mRouteBas
!=
null
)
{
addNaviListener
(
onNaviPresenterListener
)
mMineMap
=
mapReadView
?.
mMineMap
// drawNavingCar(MineRoutePlans.mStartPoint)
mNaviSession
?.
takeRoute
(
mRouteBas
)
}
}
fun
startSimNavi
(
mapReadView
:
MapReadyView
?,
starPoint
:
MSLatLng
,
routeBase
:
RouteBase
?,
onNaviPresenterListener
:
OnNaviPresenterListener
?
)
{
if
(
routeBase
!=
null
)
{
addNaviListener
(
onNaviPresenterListener
)
mMineMap
=
mapReadView
?.
mMineMap
val
point
=
Tools
.
latLngToPoint
(
LatLng
(
starPoint
.
lat
,
starPoint
.
lng
))
drawNavingCar
(
point
)
NaviSpeaker
.
stop
()
mNaviSession
?.
takeRouteQuietly
(
routeBase
)
// 设置速度
mNaviSession
?.
setEmulatorNaviSpeed
(
5.0f
)
// 开始导航
mNaviSession
?.
startSimulation
()
}
}
/**
* 直接跳转页面开启导航
*/
...
...
@@ -93,12 +119,17 @@ object MineNai {
/**
* 直接使用RouteBase开启导航
*/
fun
startNaviFormRouteBase
(
routeBase
:
RouteBase
?,
mStartPoint
:
MSLatLng
,
mapReadView
:
MapReadyView
?)
{
fun
startNaviFormRouteBase
(
routeBase
:
RouteBase
?,
mStartPoint
:
MSLatLng
,
mapReadView
:
MapReadyView
?
)
{
// mMineMap = mapReadView?.mMineMap
if
(
routeBase
==
null
)
return
mMineMap
=
mapReadView
?.
mMineMap
mNaviSession
?.
addMineNaviListener
(
myMineNaviListener
)
// mNaviSession?.removeMineNaviListeners()
// mNaviSession?.addMineNaviListener(myMineNaviListener)
val
starPoint
=
Tools
.
latLngToPoint
(
LatLng
(
mStartPoint
.
lat
,
mStartPoint
.
lng
))
drawNavingCar
(
starPoint
)
mIsInNavigation
=
true
...
...
@@ -162,44 +193,60 @@ object MineNai {
override
fun
onTracking
(
data
:
NaviSessionData
)
{
// super.onTracking(data)
onNaviPresenterListener
?.
onTracking
(
data
.
travelledDistance
.
toFloat
()
/
data
.
routeLength
)
mOnNaviListeners
.
forEach
{
it
?.
onTracking
(
data
.
travelledDistance
.
toFloat
()
/
data
.
routeLength
)
}
}
override
fun
onSmoothTracking
(
data
:
SmoothNaviData
)
{
// super.onSmoothTracking(data)
onNaviPresenterListener
?.
onSmoothTracking
(
data
)
mOnNaviListeners
.
forEach
{
it
?.
onSmoothTracking
(
data
)
}
}
override
fun
onDataUpdated
(
naviProgressData
:
NaviProgressData
)
{
// super.onDataUpdated(naviProgressData)
onNaviPresenterListener
?.
onDataUpdated
(
naviProgressData
)
mOnNaviListeners
.
forEach
{
it
?.
onDataUpdated
(
naviProgressData
)
}
}
override
fun
onTiBarUpdated
(
tmcSections
:
TmcSections
)
{
// super.onTiBarUpdated(tmcSections)
onNaviPresenterListener
?.
onTiBarUpdated
(
tmcSections
)
mOnNaviListeners
.
forEach
{
it
?.
onTiBarUpdated
(
tmcSections
)
}
}
override
fun
onTextChanged
(
guidanceText
:
GuidanceText
)
{
// super.onTextChanged(guidanceText)
onNaviPresenterListener
?.
onTextChanged
(
guidanceText
)
mOnNaviListeners
.
forEach
{
it
?.
onTextChanged
(
guidanceText
)
}
}
override
fun
onDistanceChanged
(
distance
:
Int
)
{
// super.onDistanceChanged(distance)
onNaviPresenterListener
?.
onDistanceChanged
(
distance
)
mOnNaviListeners
.
forEach
{
it
?.
onDistanceChanged
(
distance
)
}
}
override
fun
onArriveDestination
()
{
// super.onArriveDestination()
onNaviPresenterListener
?.
onArriveDestination
()
mOnNaviListeners
.
forEach
{
it
?.
onArriveDestination
()
}
}
override
fun
onNaviEnded
()
{
// super.onNaviEnded()
onNaviPresenterListener
?.
onNaviEnded
()
mOnNaviListeners
.
forEach
{
it
?.
onNaviEnded
()
}
}
}
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/maps/mine/MineRoutePlans.kt
View file @
1fced44e
...
...
@@ -68,18 +68,10 @@ object MineRoutePlans {
)
{
this
.
onDriveRoute
=
onDriveRoute
this
.
mapReadView
=
mapReadView
// var context = UserCtx.instance.mContext
mNaviSession
=
NaviSession
.
getInstance
()
// 开启语音播报
mNaviSession
?.
enableSound
(
true
)
/* var naviSessionParams = NaviSessionParams().apply {
autoReroute = true
autoRemoveRoute = true
// useMineNaviGPS = true
}
mNaviSession!!.init(context, naviSessionParams)*/
mNaviSession
?.
setDataPreference
(
DataPreference
.
preferOnline
)
mNaviSession
?.
addMineNaviListener
(
planiListener
)
...
...
mapapi/src/main/java/com/sd/api/parkroad/MsParkRoad.kt
View file @
1fced44e
...
...
@@ -8,20 +8,19 @@ import com.example.car_and_road_3d.models.Position
import
com.sd.api.MAP_TYPE
import
com.sd.api.MSDKInitializer
import
com.sd.api.bean.MyCLoc
import
com.sd.api.maps.amap.AmapMethodAdv
import
com.sd.api.maps.mine.MineMethodAdv
import
com.sd.api.maps.MsOperationParent
import
com.sd.api.ui.MapReadyView
import
com.sd.api.vms.CarRoadVM
/**
* 局部图操作类
*/
object
MsParkRoad
{
object
MsParkRoad
:
MsOperationParent
()
{
private
var
carRoadVM
:
CarRoadVM
?
=
null
/**
*设置
初始化视图回调
*设置
局部地图控制器
* @param mapReadyView 地图容器
*/
fun
setCarRoadVM
(
mapReadyView
:
MapReadyView
?)
{
...
...
@@ -35,11 +34,24 @@ object MsParkRoad {
MAP_TYPE
.
AMAP
->
{
}
}
}
/**
*更新主车
*初始化局部视图控制器
*/
/* fun initCarRoadVM() {
when (MSDKInitializer.getMapType()) {
MAP_TYPE.MINE -> {
carRoadVM = getMapReadView()?.carRoadVM
}
MAP_TYPE.AMAP -> {
}
}
}*/
/**
*更新主车我只
* @param myloc 当前位置
* @param onPrAddCar 回调
*/
...
...
@@ -247,5 +259,4 @@ object MsParkRoad {
}
}
\ No newline at end of file
mapapi/src/main/java/com/sd/api/ui/MapMultiView.kt
View file @
1fced44e
...
...
@@ -34,7 +34,7 @@ class MapMultiView : LinearLayout {
)
{
init
(
attrs
,
defStyleAttr
)
}
/**地图准备就绪监听回调****/
interface
OnMapReadyLis
{
fun
onMapReady
(
mapReadyView
:
MapReadyView
)
}
...
...
@@ -128,6 +128,33 @@ class MapMultiView : LinearLayout {
// return null
// }
/**设置指南针的显示隐藏***/
fun
setCompassView
(
show
:
Boolean
)
{
if
(
mapType
==
0
)
{
//四维地图
foreMapFragment
.
setCompassView
(
show
)
}
else
if
(
mapType
==
1
)
{
//高德地图
aMapFragment
.
setCompassView
(
show
)
}
}
/**设置比例尺的显示隐藏***/
fun
setScaleControlsEnabled
(
bool
:
Boolean
)
{
if
(
mapType
==
0
)
{
//四维地图
foreMapFragment
.
setScaleControlsEnabled
(
bool
)
}
else
if
(
mapType
==
1
)
{
//高德地图
aMapFragment
.
setScaleControlsEnabled
(
bool
)
}
}
/****设置定位按钮***/
fun
setMyLocationButtonEnabled
(
bool
:
Boolean
)
{
if
(
mapType
==
0
)
{
//四维地图
foreMapFragment
.
setMyLocationButtonEnabled
(
bool
)
}
else
if
(
mapType
==
1
)
{
//高德地图
aMapFragment
.
setMyLocationButtonEnabled
(
bool
)
}
}
}
Prev
1
2
3
4
5
6
7
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment