1、html部分
<view class="content">
<map class="maps" :markers="covers" scale="5"></map>
</view>
2、js部分
data() {
return {
latitude: '',
longitude: '',
covers:[],
shopListData:{}//存放店铺数据
}
},
onLoad(option) {
//接收从首页传过来的店铺数据
this.shopListData = JSON.parse(decodeURIComponent(option.shopList))
console.log(this.shopListData);
for(var i = 0; i < this.shopListData.length; i++){
//往covers里面push进去店铺的经纬度
var location = {}
var a = this.shopListData[i].lat
var b = this.shopListData[i].lng
location.latitude = this.shopListData[i].lat
location.longitude = this.shopListData[i].lng
location.id = i
location.iconPath = "/static/images/locate.png"
this.covers.push(location)
}console.log(this.covers);
},