vue-amap 自定义icon

使用的是content 属性
点标记显示内容,可以是HTML要素字符串或者HTML DOM对象。
content有效时,icon属性将被覆盖。
其实不使用图片,自己写个标签+样式也行的

<template>
  <div class="amap-page-container">
    <el-amap vid="amapDemo"
             :amap-manager="amapManager"
             :events="mapEvents"
             class="amap-demo">
      <el-amap-marker vid="component-marker"
                      :position="componentMarker.position"
                      :content="markerImg">
      </el-amap-marker>
    </el-amap>
  </div>
</template>
data () {
    
    
    return {
    
    
      markerImg: '<img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606470973529&di=cb79cf83cbd7a540f57d5526a5f1498e&imgtype=0&src=http%3A%2F%2Fwx4.sinaimg.cn%2Fmw690%2F005QeU4Ygy1ggo93se7joj31kw1kw49i.jpg" style="width:40px;height:40px;"></img>'
    }
}

猜你喜欢

转载自blog.csdn.net/yuyu_2019/article/details/110232607