效果:
申请腾讯地图key
uniapp项目中
<!-- uniapp中引入地图示例 -->
<template>
<view class="realTimeMonitoring">
<map style="width: 100%; height: 100vh"
:latitude="latitude"
:longitude="longitude"
:markers="covers"
:scale="scale"
:min-scale="minScale"
:max-scale="maxScale"
>
</map>
</view>
</template>
<script>
var iconPath = require('../../../../static/images/icon/forklift1.png'); // 图标位置
export default {
name: "realTimeMonitoring",
data() {
return {
// scale:
scale: 12, // 17
minScale: 3, // 最小缩放级别
maxScale: 20, // 最大缩放级别
latitude: 39.909,
longitude: 116.39742,
covers: [{
latitude: 39.909,
longitude: 116.39742,
iconPath: iconPath
},
{
latitude: 39.90,
longitude: 116.39,
iconPath: iconPath
}]
}
},
methods: {},
}
</script>
<style lang="scss" scoped>
.realTimeMonitoring {
width: 100%;
height: 100%;
}
</style>
!!!最最最重要的一步
这里填写刚刚申请的百度地图的key
附:
uniapp地图api