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(){
}
})
解决了吗?
妈的 ,我问题跟你的一模一样。头炸了
地图没加载出来?是不是两个标记的经纬度过远?试试相近的
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
<view class="" hover-class="none" hover-stop-propagation="false" style="width: 100%; height: 100%;">
<map id="map" longitude="{{longitude}}" latitude=" {{latitude}}" markers="{{markers}}" scale="15" show-location style="width: 100%; height: 100%;"></map>
</view>