1.首先创建images文件夹存放你将要自定义marker的图片
2.在wxml文件的map标签里添加markers属性
<map id="map" longitude="{{mapLng}}" latitude="{{mapLat}}" scale="{{scaleSize}}" controls="{{controls}}" bindcontroltap="controltap" markers="{{markers}}" bindmarkertap="markertap" polyline="{{polyline}}" circles="{{circles}}" bindregionchange="regionchange" show-location='true' style="width: 100%; height: {{mapHeight}}px;">
<-里面没有用到的可以不写,longitude、latitude可以写具体的经纬度,我是用getLocation获取当前位置的经纬度,然后赋值给他们了,在这不过多赘述->
3.注意此数据要写在data里面
markers:[
{
id:0
iconPath : /images/park.png
latitude :31.111145
longitude :121.385363
joinCluster:true;
width : 40
height:44
},
{
id:1
iconPath : /images/park.png
latitude :31.111145
longitude :121.385363
joinCluster:true;
width : 40
height:44
},
{
id:2
iconPath : /images/park.png
latitude :31.111145
longitude :121.385363
joinCluster:true;
width : 40
height:44
},
{
id:0
iconPath : /images/park.png
latitude :31.111145
longitude :121.385363
joinCluster:true;
width : 40
height:44
},
]
4.这样就完成啦
本文介绍如何在微信小程序中使用自定义图片作为地图标记,并通过示例展示了如何设置地图组件的markers属性来添加多个标记。
5720

被折叠的 条评论
为什么被折叠?



