Page({
data: {
latitude:34.484652,
longitude:113.313364,
markers:[]
},
onLoad:function(options) {
var that=this;
wx.getLocation({
type:"wgs84",
success: function(res){
var latitude=res.latitude;
var longitude=res.longitude;
console.log("当前位置:",res.latitude,res.longitude);
that.setData({
latitude:res.latitude,
longitude:res.longitude,
markers:[
{
id:0,
latitude:res.latitude,
longitude:res.longitude,
iconPath:"../../img/busy.png",
width:30,
height:30,
callout:{
content:"使用中",
color:'black',
fontSize:13,
borderRadius:5,
borderWidth:1,
borderColor:'#0000ff',
padding:2,
display:'ALWAYS'
},
},
{
id:1,
latitude:34.484652,
longitude:113.313364,
iconPath:"../../img/free.png",
width:30,
height:30,
callout:{
content:"空闲",
color:'red',
fontSize:13,
borderRadius:5,
borderWidth:1,
borderColor:'#0000ff',
padding:2,
display:'ALWAYS'
},
}
]
})
},
})
},
onReady:function(){
}
})
解决了吗?
地图没加载出来?是不是两个标记的经纬度过远?试试相近的