From 73a068f0ab360abc0ccaaa7aab865a39300b7975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=AB=E9=A3=8E=E5=90=B9=E8=BF=87=E7=9A=84=E5=A4=8F?= =?UTF-8?q?=E5=A4=A9?= Date: Thu, 2 Mar 2023 15:16:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=85=BE=E8=AE=AF=E5=9C=B0=E5=9B=BE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=89=8B=E7=BB=98=E5=9B=BE=E5=BC=80=E5=85=B3=EF=BC=8C?= =?UTF-8?q?=E9=92=88=E5=AF=B9=E6=99=AF=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myapplication/ui/BasicFeatureScreen.kt | 15 ++++++++++++++- .../com/melody/map/tencent_compose/MapUpdater.kt | 2 ++ .../tencent_compose/poperties/MapProperties.kt | 7 +++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/sample-tencent/src/main/java/com/melody/tencentmap/myapplication/ui/BasicFeatureScreen.kt b/sample-tencent/src/main/java/com/melody/tencentmap/myapplication/ui/BasicFeatureScreen.kt index 128b30c..738cd5c 100644 --- a/sample-tencent/src/main/java/com/melody/tencentmap/myapplication/ui/BasicFeatureScreen.kt +++ b/sample-tencent/src/main/java/com/melody/tencentmap/myapplication/ui/BasicFeatureScreen.kt @@ -40,8 +40,10 @@ import com.melody.map.tencent_compose.TXMap import com.melody.map.tencent_compose.model.MapType import com.melody.map.tencent_compose.poperties.MapProperties import com.melody.map.tencent_compose.poperties.MapUiSettings +import com.melody.map.tencent_compose.position.rememberCameraPositionState import com.melody.sample.common.model.ImmutableListWrapper import com.melody.ui.components.BasicFeatureMenuBar +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory import com.tencent.tencentmap.mapsdk.maps.model.LatLng import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds @@ -54,8 +56,8 @@ import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds */ @Composable internal fun BasicFeatureScreen() { + val cameraPositionState = rememberCameraPositionState() var uiSettings by remember { mutableStateOf(MapUiSettings()) } - var mapProperties by remember { mutableStateOf(MapProperties()) } val menuList by remember { @@ -68,6 +70,7 @@ internal fun BasicFeatureScreen() { "地图标注及名称", "实时交通状况开关", "显示室内地图开关", + "显示手绘图", "设置地图显示范围", "地图Logo缩放", "旋转手势开关", @@ -85,6 +88,7 @@ internal fun BasicFeatureScreen() { // 地图 TXMap( modifier = Modifier.matchParentSize(), + cameraPositionState = cameraPositionState, uiSettings = uiSettings, properties = mapProperties ) @@ -108,6 +112,7 @@ internal fun BasicFeatureScreen() { "地图标注及名称"-> mapProperties.isShowMapLabels "实时交通状况开关" -> mapProperties.isTrafficEnabled "显示室内地图开关" -> mapProperties.isIndoorEnabled + "显示手绘图" -> mapProperties.isHandDrawMapEnable "设置地图显示范围" -> if(mapProperties.mapShowLatLngBounds == null) null else "腾讯总部大楼" "地图Logo缩放" -> uiSettings.logoScale "旋转手势开关" -> uiSettings.isRotateGesturesEnabled @@ -152,6 +157,14 @@ internal fun BasicFeatureScreen() { "显示室内地图开关"-> { mapProperties = mapProperties.copy(isIndoorEnabled = !mapProperties.isIndoorEnabled) } + "显示手绘图"-> { + // 注意:手绘图主要用于:景区!!!!! + mapProperties = mapProperties.copy(isHandDrawMapEnable = !mapProperties.isHandDrawMapEnable) + if(mapProperties.isHandDrawMapEnable) { + // 地图视野移动,指定了经纬度和缩放级别 + cameraPositionState.move(CameraUpdateFactory.newLatLngZoom(LatLng(25.072295,102.761478), 18F)) + } + } "设置地图显示范围"-> { if(mapProperties.mapShowLatLngBounds == null) { // 设置地图只显示腾讯总部大楼这个区域的地图范围 diff --git a/tencent-map-compose/src/main/java/com/melody/map/tencent_compose/MapUpdater.kt b/tencent-map-compose/src/main/java/com/melody/map/tencent_compose/MapUpdater.kt index 225d16b..410988c 100644 --- a/tencent-map-compose/src/main/java/com/melody/map/tencent_compose/MapUpdater.kt +++ b/tencent-map-compose/src/main/java/com/melody/map/tencent_compose/MapUpdater.kt @@ -149,6 +149,8 @@ internal inline fun MapUpdater( set(mapProperties.isShowBuildings) { map.setBuilding3dEffectEnable(it) } // 是否显示室内地图 set(mapProperties.isIndoorEnabled) { map.setIndoorEnabled(it) } + // 是否显示手绘图,**手绘图的主要应用场景是:景区** + set(mapProperties.isHandDrawMapEnable) { map.isHandDrawMapEnable = it } // 是否显示路况图层 set(mapProperties.isTrafficEnabled) { map.isTrafficEnabled = it } // 指南针控件是否可见 diff --git a/tencent-map-compose/src/main/java/com/melody/map/tencent_compose/poperties/MapProperties.kt b/tencent-map-compose/src/main/java/com/melody/map/tencent_compose/poperties/MapProperties.kt index d96a6a4..da495f9 100644 --- a/tencent-map-compose/src/main/java/com/melody/map/tencent_compose/poperties/MapProperties.kt +++ b/tencent-map-compose/src/main/java/com/melody/map/tencent_compose/poperties/MapProperties.kt @@ -40,6 +40,7 @@ val DefaultMapProperties = MapProperties() * @param restrictHeightBounds 基于高度显示地图范围: tencentMap.setRestrictBounds(latLngBounds, RestrictBoundsFitMode.FIT_HEIGHT) * @param isMyLocationEnabled 设置是否打开定位图层(myLocationOverlay) * @param isTrafficEnabled 是否打开交通路况图层 + * @param isHandDrawMapEnable 是否显示手绘图,**手绘图的主要应用场景是:景区** * @param myLocationStyle 设置定位图层(myLocationOverlay)的样式 * @param maxZoomPreference 设置地图最大缩放级别 缩放级别范围为[3, 20],超出范围将按最大级别计算 * @param minZoomPreference 设置最小缩放级别 缩放级别范围为[3, 20],超出范围将按最小级别计算 @@ -55,6 +56,7 @@ class MapProperties( val restrictHeightBounds: LatLngBounds? = null, val isMyLocationEnabled: Boolean = false, val isTrafficEnabled: Boolean = false, + val isHandDrawMapEnable: Boolean = false, val myLocationStyle: MyLocationStyle? = null, val maxZoomPreference: Float = 21.0F, val minZoomPreference: Float = 0F, @@ -71,6 +73,7 @@ class MapProperties( restrictHeightBounds == other.restrictHeightBounds && isMyLocationEnabled == other.isMyLocationEnabled && isTrafficEnabled == other.isTrafficEnabled && + isHandDrawMapEnable == other.isHandDrawMapEnable && myLocationStyle == other.myLocationStyle && maxZoomPreference == other.maxZoomPreference && minZoomPreference == other.minZoomPreference && @@ -86,6 +89,7 @@ class MapProperties( restrictHeightBounds, isMyLocationEnabled, isTrafficEnabled, + isHandDrawMapEnable, myLocationStyle, maxZoomPreference, minZoomPreference, @@ -102,6 +106,7 @@ class MapProperties( restrictHeightBounds: LatLngBounds? = this.restrictHeightBounds, isMyLocationEnabled: Boolean = this.isMyLocationEnabled, isTrafficEnabled: Boolean = this.isTrafficEnabled, + isHandDrawMapEnable: Boolean = this.isHandDrawMapEnable, myLocationStyle: MyLocationStyle? = this.myLocationStyle, maxZoomPreference: Float = this.maxZoomPreference, minZoomPreference: Float = this.minZoomPreference, @@ -116,6 +121,7 @@ class MapProperties( restrictHeightBounds = restrictHeightBounds, isMyLocationEnabled = isMyLocationEnabled, isTrafficEnabled = isTrafficEnabled, + isHandDrawMapEnable = isHandDrawMapEnable, myLocationStyle = myLocationStyle, maxZoomPreference = maxZoomPreference, minZoomPreference = minZoomPreference, @@ -132,6 +138,7 @@ class MapProperties( "restrictHeightBounds=$restrictHeightBounds, " + "isMyLocationEnabled=$isMyLocationEnabled, " + "isTrafficEnabled=$isTrafficEnabled, " + + "isHandDrawMapEnable=$isHandDrawMapEnable, " + "myLocationStyle=$myLocationStyle, " + "maxZoomPreference=$maxZoomPreference, " + "minZoomPreference=$minZoomPreference, " +