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}}" bindregiοnchange="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.这样就完成啦