Skip to content

Commit

Permalink
腾讯地图增加手绘图开关,针对景区
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMelody committed Mar 2, 2023
1 parent 081d3b9 commit 73a068f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 {
Expand All @@ -68,6 +70,7 @@ internal fun BasicFeatureScreen() {
"地图标注及名称",
"实时交通状况开关",
"显示室内地图开关",
"显示手绘图",
"设置地图显示范围",
"地图Logo缩放",
"旋转手势开关",
Expand All @@ -85,6 +88,7 @@ internal fun BasicFeatureScreen() {
// 地图
TXMap(
modifier = Modifier.matchParentSize(),
cameraPositionState = cameraPositionState,
uiSettings = uiSettings,
properties = mapProperties
)
Expand All @@ -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
Expand Down Expand Up @@ -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) {
// 设置地图只显示腾讯总部大楼这个区域的地图范围
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
// 指南针控件是否可见
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],超出范围将按最小级别计算
Expand All @@ -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,
Expand All @@ -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 &&
Expand All @@ -86,6 +89,7 @@ class MapProperties(
restrictHeightBounds,
isMyLocationEnabled,
isTrafficEnabled,
isHandDrawMapEnable,
myLocationStyle,
maxZoomPreference,
minZoomPreference,
Expand All @@ -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,
Expand All @@ -116,6 +121,7 @@ class MapProperties(
restrictHeightBounds = restrictHeightBounds,
isMyLocationEnabled = isMyLocationEnabled,
isTrafficEnabled = isTrafficEnabled,
isHandDrawMapEnable = isHandDrawMapEnable,
myLocationStyle = myLocationStyle,
maxZoomPreference = maxZoomPreference,
minZoomPreference = minZoomPreference,
Expand All @@ -132,6 +138,7 @@ class MapProperties(
"restrictHeightBounds=$restrictHeightBounds, " +
"isMyLocationEnabled=$isMyLocationEnabled, " +
"isTrafficEnabled=$isTrafficEnabled, " +
"isHandDrawMapEnable=$isHandDrawMapEnable, " +
"myLocationStyle=$myLocationStyle, " +
"maxZoomPreference=$maxZoomPreference, " +
"minZoomPreference=$minZoomPreference, " +
Expand Down

0 comments on commit 73a068f

Please sign in to comment.