小程序map组件展示当前位置修改标记点图标
⼩程序map组件展⽰当前位置修改标记点图标
当前位置展⽰:
<view>
<map id="myMap"show-location class="container"  />
</view>
onShow:function(){
this.mapCtx = wx.createMapContext('myMap')
veToLocation()
}
改个标记点的默认样式:
⽅法⼀、
小红旗图标怎么弄<view>
<map id="myMap"scale="16"markers="{{markers}}"bindmarkertap="markertap"bindregionchange="regionchange"show-location ></map>
</view>
markers:[{
iconPath:"../../static/images/home/icon.png",
longitude:121.45088,
latitude:31.25145,
id:0,
width:34,
height:49
}]
},
regionchange(e){
console.log(e)
},
markertap(e){
console.log(e)
},
onShow:function(){
this.mapCtx = wx.createMapContext('myMap')
veToLocation()
const lat="markers[0].latitude";
const log="markers[0].longitude";
var that =this;
type:"wgs84",
success:function(res){
that.setData({
[lat]:res.latitude,
[log]:res.longitude
})
}
})
}
})
⽅法⼆、
<view>
<map id="map"longitude="{{longitude}}"latitude="{{latitude}}"scale="16"markers="{{markers}}"bindmarkertap="markertap"bindregionchange="regionch ange"show-location ></map>
</view>
longitude:121.45088,
latitude:31.25145,
markers:[{
iconPath:"../../static/images/home/icon.png",  longitude:121.45088,
latitude:31.25145,
id:0,
width:34,
height:49
}]
},
regionchange(e){
console.log(e)
},
markertap(e){
console.log(e)
},
onShow:function(){
const lat="markers[0].latitude";
const log="markers[0].longitude";
var that =this;
type:"wgs84",
success:function(res){
that.setData({
latitude: res.latitude,
longitude: res.longitude,
[lat]:res.latitude,
[log]:res.longitude
})
}
})
}
})

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。