uni-app APP-IOS端使用map组件时,手指在customCallout上无法拖动地图
uni-app APP-IOS端使用map组件时,手指在customCallout上无法拖动地图
<template>
<view class="content">
<map class="map" id="map1" ref="map1" :controls="controls" :scale="scale" :longitude="location.longitude"
:latitude="location.latitude" :show-location="showLocation" :rotate="rotate" :skew="skew" show-scale="true"
:markers="markers" enable-building=true enable-indoorMap="true" @callouttap="oncallouttap">
<cover-view slot="callout">
<cover-view marker-id="1">
<cover-image class="icon" src="/static/logo.png"></cover-image>
<cover-view class="test">
customCallout
</cover-view>
</cover-view>
</cover-view>
</map>
</view>
</template>
<script>
const testMarkers = [{
id: 1,
latitude: 39.9086920000,
longitude: 116.3974770000,
title: '天安门',
zIndex: '1',
iconPath: '/static/gif.gif',
width: 40,
height: 40,
anchor: {
x: 0.5,
y: 1
},
callout: {
content: '首都北京\n天安门',
color: '#00BFFF',
fontSize: 12,
borderRadius: 2,
borderWidth: 0,
borderColor: '#333300',
bgColor: '#CCFF11',
padding: '1',
display: 'ALWAYS'
},
customCallout: {
anchorY: 0,
anchorX: 0,
display: 'ALWAYS'
}
}];
module.exports = {
data() {
return {
location: {
longitude: 116.3974770000,
latitude: 39.9086920000
},
controls: [{
id: 1,
position: {
left: 5,
top: 180,
width: 30,
height: 30
},
iconPath: '/static/logo.png',
clickable: true
}],
showLocation: false,
scale: 13,
enableZoom: true,
polyline: [],
markers: testMarkers,
polygons: [],
circles: [],
includePoints: [],
rotate: 0,
skew: 0
}
},
methods: {
oncallouttap(e) {
uni.showModal({
content: JSON.stringify(e)
})
}
}
}
</script>
<style>
.content {
flex: 1;
}
.map {
width: 750rpx;
height: 250px;
background-color: #f0f0f0;
}
.icon {
width: 20px;
height: 20px;
}
.scrollview {
flex: 1;
padding: 10px;
}
.list-item {
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
padding: 5px 0px;
}
.list-text {
flex: 1;
}
.button {
margin-top: 5px;
margin-bottom: 5px;
}
</style>
更多关于uni-app APP-IOS端使用map组件时,手指在customCallout上无法拖动地图的实战教程也可以访问 https://www.itying.com/category-93-b0.html
8 回复
问题复现,已给相关人员排查,已加分感谢反馈!
更多关于uni-app APP-IOS端使用map组件时,手指在customCallout上无法拖动地图的实战教程也可以访问 https://www.itying.com/category-93-b0.html
这是高德地图默认实现,不管是默认的 callout 还是 customCallout 都一样的,属于是平台差异
就是说IOS端这个问题无解是吗?为什么参考其他使用高德地图的APP,可以实现呢?
回复 1***@qq.com: 暂时不会哦,这个是高德sdk默认实现就是这样
这不应该是正常的吗?!?
你没话说可以不回复,非要来刷个存在感吗
这是一个iOS端map组件与customCallout交互的问题。主要原因是iOS上customCallout会拦截触摸事件,导致无法拖动地图。
解决方法有以下几种:
- 使用cover-view替代customCallout:
<map>
<cover-view slot="callout">
<cover-view marker-id="1">
<!-- 自定义内容 -->
</cover-view>
</cover-view>
</map>
- 在customCallout上添加pointer-events属性:
.custom-callout {
pointer-events: none;
}
- 使用marker的callout属性代替customCallout:
markers: [{
callout: {
content: '文本内容',
display: 'ALWAYS'
}
}]
- 监听touch事件手动处理:
[@touchstart](/user/touchstart)="handleTouchStart"
[@touchmove](/user/touchmove)="handleTouchMove"