<template>
<map id="mapid" class="map1" ref="map1" scale="16" @tap="tapHandler" @callouttap="markertapHandler" @regionchange="regionchangeHandler" :polygons="props.location" :latitude="props.latitude" :longitude="props.longitude" :markers="props.avgMarkers"></map>
</template>
<script setup>
import { ref, defineProps, onMounted, getCurrentInstance } from 'vue'
const props = defineProps({
polygons: Array,
latitude: Number,
longitude: Number,
markers: Array
})
const con = ref()
const instance = ref()
const ids = ref(666)
onMounted(() => {
var pages = getCurrentPages()
var page = pages[pages.length - 1]
instance.value = getCurrentInstance()
// #ifdef APP-PLUS
var currentWebview = page.$getAppWebview()
console.log(currentWebview.id) //获得当前webview的id
console.log(currentWebview.isVisible()) //查询当前webview是否可见
con.value = uni.createMapContext('mapid', instance.value)
console.log(con.value, 'concon')
// #endif
})
const markertapHandler = e => {}
const regionchangeHandler = e => {}
const tapHandler = e => {
console.log('first')
con.value.getScale({
success: function (res) {
console.log(res, '执行了吗')
},
fail: function (res) {
console.log(res, '失败了')
}
})
}
</script>
<style lang="scss" scoped>
.map1 {
width: 750rpx;
height: 1000rpx;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
</style>