在小程序中,局部地图可设置地图组件进行完成,
wxml:
<view class="Map">
<map id="map" longitude="{
{longitude}}" latitude="{
{latitude}}" show-location="true">
</map>
</view>
wxss:
.Map{
width: 100%;
height: 80%;
display:flex;
}
#map{
width: 100%;
height: 200px;
}
js:
data: {
//自定义标记点数组
markers: [],
//纬度
latitude: '',
//经度
longitude: '',
}
onLoad: function () {
var that = this;
// 获取当前定位的经纬度信息
wx.showLoading({
title: "定位中",
mask: true
})
wx.getLocation({
type: 'gcj02',
altitude: true, //高精度定位
//定位成功,更新定位结果
success: func