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
aa564e16
Commit
aa564e16
authored
Aug 22, 2025
by
p x
Browse files
增加工厂方法
parent
c6411612
Changes
20
Show whitespace changes
Inline
Side-by-side
.idea/misc.xml
View file @
aa564e16
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ExternalStorageConfigurationManager"
enabled=
"true"
/>
<component
name=
"JavadocGenerationManager"
>
<option
name=
"OUTPUT_DIRECTORY"
value=
"$PROJECT_DIR$/.."
/>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_21"
default=
"true"
project-jdk-name=
"jbr-21"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
...
...
app/src/main/java/com/sd/mapmultiengine/LayerManage.java
View file @
aa564e16
...
...
@@ -64,7 +64,7 @@ public class LayerManage {
public
URL
getTileUrl
(
int
x
,
int
y
,
int
zoom
)
{
// 构建WMS图层URL
try
{
System
.
out
.
println
(
x
+
"/"
+
y
+
"/"
+
zoom
+
"=====>"
+
url
+
TitleBounds
(
x
,
y
,
zoom
));
//
System.out.println(x + "/" + y + "/" + zoom + "=====>" + url + TitleBounds(x, y, zoom));
return
new
URL
(
url
+
TitleBounds
(
x
,
y
,
zoom
));
}
catch
(
MalformedURLException
e
)
{
e
.
printStackTrace
();
...
...
@@ -76,7 +76,8 @@ public class LayerManage {
// 添加TileOverlay
tileOverlay
=
aMap
.
addTileOverlay
(
tileOverlayOptions
);
LatLng
latLng
=
new
LatLng
(
39.80870258484975
,
116.5011886304098
);
// LatLng latLng = new LatLng(39.80870258484975, 116.5011886304098);
LatLng
latLng
=
new
LatLng
(
43.838481
,
125.143485
);
//长春中心点坐标
aMap
.
moveCamera
(
CameraUpdateFactory
.
newLatLngZoom
(
latLng
,
18.0f
));
return
tileOverlay
;
}
...
...
app/src/main/java/com/sd/mapmultiengine/MainActivity.kt
View file @
aa564e16
...
...
@@ -59,11 +59,12 @@ class MainActivity : AppCompatActivity() {
DemoDetails
(
"两点间距离计算"
,
CalculateDistanceActivity
::
class
.
java
),
DemoDetails
(
"定位,获取我的位置"
,
TGpsActivity
::
class
.
java
),
DemoDetails
(
"在线地图显示小车"
,
ShowCarOnlineActivity
::
class
.
java
),
DemoDetails
(
"驾车路线规划"
,
TDriveRouteActivity
::
class
.
java
),
DemoDetails
(
"业务相关"
,
null
),
DemoDetails
(
"在线地图显示小车"
,
ShowCarOnlineActivity
::
class
.
java
),
DemoDetails
(
"测试高德加载WMS"
,
AMapWmsActivity
::
class
.
java
),
...
...
@@ -116,7 +117,7 @@ class MainActivity : AppCompatActivity() {
}
fun
initMap
(
type
:
MAP_TYPE
=
MAP_TYPE
.
MINE
)
{
fun
initMap
(
type
:
MAP_TYPE
=
MAP_TYPE
.
AMAP
)
{
MSDKInitializer
.
initializeMap
(
this
,
type
,
object
:
OnSdkInitCb
{
override
fun
onInitSuccess
()
{
println
(
"--------onMapInitSuccess"
)
...
...
app/src/main/java/com/sd/mapmultiengine/ui/AMapWmsActivity.kt
View file @
aa564e16
...
...
@@ -18,12 +18,14 @@ class AMapWmsActivity : AppCompatActivity() {
private
var
aMap
:
AMap
?
=
null
// var url =
// "https://faw.cuscavp.cn:8443/geoserver/changchun/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=true"
var
url
:
String
=
"http://10.166.15.10:8080/geoserver/cusc/wms?LAYERS=cusc%3AHMI_GJDT&FORMAT=image%2Fpng&TRANSPARENT=TRUE&SERVICE="
+
"WMS&VERSION=1.1.0&REQUEST=GetMap&STYLES=&SRS=EPSG:3857&BBOX="
var
url
:
String
=
"https://faw.cuscavp.cn:8443/geoserver/changchun/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=true"
//var url: String =
// "https://faw.cuscavp.cn:8443/geoserver/changchun/wms?service=WMS&version=1.1.0&request=GetMap&srs=EPSG:4326&styles="
//var url: String =
// "http://192.168.59.216/geoserver/wms?LAYERS=zx1&FORMAT=image%2Fpng&TRANSPARENT=TRUE&SERVICE=" +
// "WMS&VERSION=1.1.0&REQUEST=GetMap&STYLES=&SRS=EPSG:3857&BBOX="
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
enableEdgeToEdge
()
...
...
app/src/main/java/com/sd/mapmultiengine/ui/ShowCarOnlineActivity.kt
View file @
aa564e16
...
...
@@ -33,11 +33,10 @@ class ShowCarOnlineActivity : AppCompatActivity() {
binding
.
mapMultiView
.
addMapRenderCallback
(
object
:
OnMapReadyLis
{
override
fun
onMapReady
(
mapReadyView
:
MapReadyView
)
{
this
@ShowCarOnlineActivity
.
mapReadView
=
mapReadyView
//添加小车
//
地图加载完成后
添加小车
var
center
=
MSLatLng
(
39.787678
,
116.518766
)
MSMethodAdv
.
setMapCenter
(
mapReadView
,
center
.
lat
,
center
.
lng
)
MShowMainCarModel
.
addMyLocCarModel
(
mapReadView
,
this
@ShowCarOnlineActivity
,
center
.
lat
,
center
.
lng
,
0f
)
}
})
//显示小车
...
...
@@ -51,9 +50,10 @@ class ShowCarOnlineActivity : AppCompatActivity() {
//初始化定位
MSGpsLocation
.
initLoc
(
this
)
//设置回调
//设置
定位
回调
MSGpsLocation
.
setOnMsGpsLoc
(
object
:
MSGpsLocation
.
OnMsGpsLoc
{
override
fun
onMsGpsLoc
(
mSLocBean
:
MSLocBean
)
{
//在这里改变小车的位置
}
})
...
...
app/src/main/java/com/sd/mapmultiengine/ui/TDriveRouteActivity.kt
View file @
aa564e16
...
...
@@ -32,6 +32,7 @@ import com.sd.maplibrary.MSDKInitializer
import
com.sd.maplibrary.bean.DriverRouteBean
import
com.sd.maplibrary.bean.MSLatLng
import
com.sd.maplibrary.bean.RouteOver
import
com.sd.maplibrary.bean.WayPoi
import
com.sd.maplibrary.core.MSRoutePlans
import
com.sd.maplibrary.core.MSRoutePlans.OnDriveRoute
import
com.sd.maplibrary.core.MapReadyView
...
...
@@ -40,15 +41,13 @@ import com.sd.mapmultiengine.databinding.ActivityTdriveRouteBinding
import
com.amap.api.services.core.LatLonPoint
as
ALatLonPoint
/******/
/***
驾车路径规划
***/
class
TDriveRouteActivity
:
AppCompatActivity
()
{
private
lateinit
var
binding
:
ActivityTdriveRouteBinding
var
mapReadView
:
MapReadyView
?
=
null
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
binding
=
ActivityTdriveRouteBinding
.
inflate
(
layoutInflater
)
...
...
@@ -72,8 +71,13 @@ class TDriveRouteActivity : AppCompatActivity() {
val
endPoint
=
MSLatLng
(
39.864311
,
116.379311
)
//// 终点名称
val
endName
=
"沈阳火车站"
var
wayPoi
=
WayPoi
().
apply
{
passName
=
"鸟巢"
passPoint
=
MSLatLng
(
39.99300
,
116.39524
)
}
var
ways
=
listOf
<
WayPoi
>(
wayPoi
)
//开始路径规划
MSRoutePlans
.
drivingPathPlanning
(
this
,
startPoint
,
endPoint
,
endName
)
MSRoutePlans
.
drivingPathPlanning
(
this
,
startPoint
,
endPoint
,
ways
,
endName
)
// testDriverPlan()
// testDriverPlanaMAP()
...
...
app/src/main/res/layout/activity_tdrive_route.xml
View file @
aa564e16
...
...
@@ -9,7 +9,7 @@
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"北京南站 - 沈阳火车站"
/>
android:text=
"北京南站 - 沈阳火车站
途经点鸟巢
"
/>
<Button
...
...
build.gradle.kts
View file @
aa564e16
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript
{
dependencies
{
classpath
(
"org.jetbrains.dokka:dokka-gradle-plugin:2.0.0"
)
}
}
plugins
{
alias
(
libs
.
plugins
.
android
.
application
)
apply
false
alias
(
libs
.
plugins
.
kotlin
.
android
)
apply
false
...
...
maplibrary/build.gradle.kts
View file @
aa564e16
...
...
@@ -2,6 +2,8 @@ plugins {
alias
(
libs
.
plugins
.
android
.
library
)
alias
(
libs
.
plugins
.
kotlin
.
android
)
id
(
"kotlin-kapt"
)
// kotlin("jvm") version "2.0.21" // 替换x.y.z为你的Kotlin版本
id
(
"org.jetbrains.dokka"
)
// version("2.0.0") // 确保使用正确的Dokka版本
}
...
...
@@ -36,6 +38,25 @@ android {
// dataBinding = true
viewBinding
=
true
}
// dokka {
// outputFormat = 'javadoc'
// outputDirectory = "$buildDir/dokka"
//
// configuration {
// // Do not output deprecated members
// skipDeprecated = true
// // Emit warnings about not documented members.
// reportUndocumented = true
// // Do not create index pages for empty packages
// skipEmptyPackages = true
//
// noJdkLink = true
// noStdlibLink = true
// noAndroidSdkLink = true
// }
// }
}
//repositories {
...
...
maplibrary/src/main/java/com/sd/maplibrary/MSDKInitializer.kt
View file @
aa564e16
...
...
@@ -20,7 +20,7 @@ enum class MAP_TYPE {
AMAP
}
/**用户传入上下文***/
private
class
UserCtx
{
var
mContext
:
Context
?
=
null
var
map_type
:
MAP_TYPE
=
MAP_TYPE
.
MINE
...
...
maplibrary/src/main/java/com/sd/maplibrary/bean/WayPoi.kt
0 → 100644
View file @
aa564e16
package
com.sd.maplibrary.bean
/***途经点Poi***/
class
WayPoi
{
//途经点名坐标
var
passPoint
:
MSLatLng
?
=
null
//途经点名字
var
passName
=
""
}
\ No newline at end of file
maplibrary/src/main/java/com/sd/maplibrary/core/MSGpsLocation.kt
View file @
aa564e16
package
com.sd.maplibrary.core
import
android.annotation.SuppressLint
import
android.content.Context
import
android.os.Bundle
import
com.amap.api.location.AMapLocation
...
...
@@ -50,8 +51,10 @@ object MSGpsLocation {
return
@lazy
mOption
}
private
var
locationClient
:
AMapLocationClient
?
=
null
/****业务层Gps定位回调**/
private
var
onMsGpsLoc
:
OnMsGpsLoc
?
=
null
/***初始化监听定位**/
...
...
@@ -61,6 +64,7 @@ object MSGpsLocation {
MineLocationManager
.
getInstance
()
.
init
(
context
,
MineLocationManager
.
LocationSource
.
gpsAndNetwork
)
// MineLocationManager.getInstance().removeListener(mineLocationListener)
MineLocationManager
.
getInstance
().
addListener
(
mineLocationListener
)
}
...
...
maplibrary/src/main/java/com/sd/maplibrary/core/MSRoutePlans.kt
View file @
aa564e16
...
...
@@ -8,10 +8,9 @@ import com.amap.api.navi.AMapNavi
import
com.amap.api.navi.AmapNaviPage
import
com.amap.api.navi.AmapNaviParams
import
com.amap.api.navi.AmapNaviType
import
com.amap.api.navi.
enums.PathPlanningStrategy
import
com.amap.api.navi.
AmapPageType
import
com.amap.api.navi.model.AMapCalcRouteResult
import
com.amap.api.navi.model.AMapNaviPath
import
com.amap.api.navi.model.NaviLatLng
import
com.amap.api.navi.view.RouteOverLay
import
com.minedata.minenavi.map.Route
import
com.minedata.minenavi.map.RouteOptions
...
...
@@ -29,10 +28,10 @@ import com.sd.maplibrary.MAP_TYPE
import
com.sd.maplibrary.MSDKInitializer
import
com.sd.maplibrary.bean.DriverRouteBean
import
com.sd.maplibrary.bean.MSLatLng
import
com.sd.maplibrary.bean.WayPoi
import
com.sd.maplibrary.intfaces.MyAMapNaviListener
import
com.sd.maplibrary.intfaces.MyMineNaviListener
import
com.sd.maplibrary.utils.DisplayUtil
import
kotlin.contracts.contract
import
com.amap.api.maps.model.LatLng
as
ALatLng
...
...
@@ -104,12 +103,14 @@ object MSRoutePlans {
/***驾车路径规划,直接跳转到 导航页面
*@param starPoint 起点坐标
* @param endPoint 终点坐标
* @param ways 途经点集合
* @param endName 终点名称(高德可不传)
* ***/
fun
drivingPathPlanning
(
context
:
Context
,
starPoint
:
MSLatLng
,
endPoint
:
MSLatLng
,
ways
:
List
<
WayPoi
>,
endName
:
String
=
""
,
startName
:
String
=
"当前位置"
)
{
...
...
@@ -119,7 +120,14 @@ object MSRoutePlans {
val
endPoint
=
Tools
.
latLngToPoint
(
LatLng
(
endPoint
.
lat
,
endPoint
.
lng
))
var
startName
=
startName
var
endName
=
endName
var
wayPoints
=
listOf
<
PoiFavorite
>()
var
wayPoints
=
mutableListOf
<
PoiFavorite
>()
if
(
ways
.
count
()
>
0
)
{
ways
.
forEach
{
wpoi
->
var
passPoint
=
Tools
.
latLngToPoint
(
LatLng
(
wpoi
.
passPoint
!!
.
lat
,
wpoi
.
passPoint
!!
.
lng
))
wayPoints
.
add
(
PoiFavorite
(
passPoint
,
wpoi
.
passName
))
}
}
val
routePlan
=
RoutePlan
()
routePlan
.
setRoutePreference
(
RoutePlan
.
RoutePreference
.
none
)
routePlan
.
setTransportationType
(
RoutePlan
.
TransportationType
.
car
)
...
...
@@ -134,6 +142,7 @@ object MSRoutePlans {
}
MAP_TYPE
.
AMAP
->
{
//这是路径规划
// var startLatlng = NaviLatLng(starPoint.lat, starPoint.lng)
// var startList = listOf<NaviLatLng>(startLatlng)
//
...
...
@@ -148,10 +157,21 @@ object MSRoutePlans {
// PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT
// )
//途经点
var
poiList
=
mutableListOf
<
Poi
>()
if
(
ways
.
count
()
>
0
)
{
ways
.
forEach
{
wpoi
->
poiList
.
add
(
Poi
(
"鸟巢"
,
ALatLng
(
wpoi
.
passPoint
!!
.
lat
,
wpoi
.
passPoint
!!
.
lng
),
""
))
}
}
//这是导航,直接到高德内置组件
val
params
=
AmapNaviParams
(
Poi
(
startName
,
ALatLng
(
starPoint
.
lat
,
starPoint
.
lng
),
""
),
null
,
Poi
(
startName
,
ALatLng
(
starPoint
.
lat
,
starPoint
.
lng
),
""
),
poiList
,
Poi
(
endName
,
ALatLng
(
endPoint
.
lat
,
endPoint
.
lng
),
""
),
AmapNaviType
.
DRIVER
AmapNaviType
.
DRIVER
,
AmapPageType
.
ROUTE
)
params
.
setUseInnerVoice
(
true
)
AmapNaviPage
.
getInstance
()
...
...
maplibrary/src/main/java/com/sd/maplibrary/core/MShowMainCarModel.kt
View file @
aa564e16
...
...
@@ -11,6 +11,8 @@ import com.minedata.minenavi.map.Overlay
import
com.minedata.minenavi.mapdal.LatLng
import
com.sd.maplibrary.MAP_TYPE
import
com.sd.maplibrary.MSDKInitializer
import
com.sd.maplibrary.bean.MSLatLng
import
com.sd.maplibrary.utils.SmoothMoveUtils
import
com.sd.shupathwebview.utils.FileIoUtils
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
...
...
@@ -94,7 +96,11 @@ object MShowMainCarModel {
}
/****更新模型**/
/**更新模型位置
* @param lat 纬度
* @param lng 经度
* @param heading 航向角
* **/
fun
upMyLocCarModel
(
lat
:
Double
,
lng
:
Double
,
...
...
@@ -117,15 +123,24 @@ object MShowMainCarModel {
}
/****更新模型**/
/**平滑更新模型
* @param from 开始经纬度
* @param to 结束经纬度
* @param durationMillis 动画时长默认1000L
* **/
fun
upMyLocCarModelSmooth
(
lat
:
Double
,
lng
:
Double
,
heading
:
Float
from
:
MSLatLng
,
to
:
MSLatLng
,
durationMillis
:
Long
=
1000L
)
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
SmoothMoveUtils
.
startSmoothMove
(
LatLng
(
from
.
lat
,
from
.
lng
),
LatLng
(
from
.
lat
,
from
.
lng
),
durationMillis
,
sCarSmooth
)
}
MAP_TYPE
.
AMAP
->
{
...
...
@@ -135,4 +150,31 @@ object MShowMainCarModel {
}
//在线地图主车平滑移动
private
var
sCarSmooth
=
object
:
SmoothMoveUtils
.
OnPositionUpdateListener
{
override
fun
onUpdate
(
interpolatedLatLng
:
LatLng
,
bearing
:
Float
)
{
// var gcj = CoordinateTransform.wgs84ToGcj02(
// interpolatedLatLng.longitude,
// interpolatedLatLng.latitude
// )
// mapOpt.upMyLocCarModel(
// interpolatedLatLng.latitude,
// interpolatedLatLng.longitude,
// bearing
// )
}
override
fun
onFinish
()
{
println
(
"--------------动画完成"
)
// carRoadVM.oldVeh = carRoadVM.eVehicle.value
}
}
}
\ No newline at end of file
maplibrary/src/main/java/com/sd/maplibrary/fragments/ForeMapFragment.kt
View file @
aa564e16
...
...
@@ -101,7 +101,6 @@ class ForeMapFragment : Fragment() {
override
fun
onDestroy
()
{
super
.
onDestroy
()
binding
.
mapView
.
onDestroy
()
binding
.
mapView
.
map
}
companion
object
{
...
...
maplibrary/src/main/java/com/sd/maplibrary/intfaces/AMapCore.kt
0 → 100644
View file @
aa564e16
package
com.sd.maplibrary.intfaces
/***高德实现类***/
class
AMapCore
:
MapFuncs
{
companion
object
{
val
aMapCore
:
AMapCore
by
lazy
{
AMapCore
()
}
}
}
\ No newline at end of file
maplibrary/src/main/java/com/sd/maplibrary/intfaces/MapFactory.kt
0 → 100644
View file @
aa564e16
package
com.sd.maplibrary.intfaces
import
com.sd.maplibrary.MAP_TYPE
import
com.sd.maplibrary.MSDKInitializer
/***地图工厂**/
object
MapFactory
{
/***获取四维或者高德的实例****/
fun
getMapInstance
():
MapFuncs
{
when
(
MSDKInitializer
.
getMapType
())
{
MAP_TYPE
.
MINE
->
{
return
MineCore
.
mineCore
}
MAP_TYPE
.
AMAP
->
{
return
AMapCore
.
aMapCore
}
}
}
}
\ No newline at end of file
maplibrary/src/main/java/com/sd/maplibrary/intfaces/MapFuncs.kt
0 → 100644
View file @
aa564e16
package
com.sd.maplibrary.intfaces
/****Map 业务接口**/
interface
MapFuncs
{
}
\ No newline at end of file
maplibrary/src/main/java/com/sd/maplibrary/intfaces/MineCore.kt
0 → 100644
View file @
aa564e16
package
com.sd.maplibrary.intfaces
/****四维实现类***/
class
MineCore
:
MapFuncs
{
companion
object
{
val
mineCore
:
MineCore
by
lazy
{
MineCore
()
}
}
}
\ No newline at end of file
settings.gradle.kts
View file @
aa564e16
...
...
@@ -18,6 +18,11 @@ pluginManagement {
dependencyResolutionManagement
{
repositoriesMode
.
set
(
RepositoriesMode
.
FAIL_ON_PROJECT_REPOS
)
repositories
{
maven
{
setUrl
(
"https://maven.aliyun.com/repository/central"
)
}
maven
{
setUrl
(
"https://maven.aliyun.com/repository/jcenter"
)
}
maven
{
setUrl
(
"https://maven.aliyun.com/repository/google"
)
}
maven
{
setUrl
(
"https://maven.aliyun.com/repository/gradle-plugin"
)
}
maven
{
setUrl
(
"https://maven.aliyun.com/repository/public"
)
}
google
()
mavenCentral
()
}
...
...
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