uni-app的App端点击Map组件获取经纬度的方法

注意:map组件如果放在uni-popup里面会有层级问题,造成不显示的问题,我是直接放在根元素下面,控制显隐解决的

<map ref='popMap' v-show="popShow" id="popMap"

style="width:680rpx;box-sizing: border-box; height: 60vh;position: absolute;z-index: 1000; bottom:200rpx "

:latitude="latitude" :longitude="longitude" :markers="markers" @tap='addSite'>

</map>

addMapEvent() {

let that = this;

var maps = uni.createMapContext("popMap", this).$getAppMap();

maps.onclick = function(point) {

console.log(point);

that.lon = point.longitude

that.lat = point.latitude

that.markers = [];

that.markers = [{

id: 1,

latitude: point.latitude,

longitude: point.longitude,

iconPath: marker,

title: "我的位置"

}]

}

},


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容