vue2-google-maps 的自定义标记 [英] custom marker for vue2-google-maps

查看:115
本文介绍了vue2-google-maps 的自定义标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 vue2-google-maps 没有成功.我知道这是一个错误,当我在标签中添加 :icon="{url:'../assets/my_image'}" 时,标记消失.有没有人设法让它工作?

I am trying to add my own images for a custom marker in vue2-google-maps without success. I know this is a bug and when I add an :icon="{url:'../assets/my_image'}" in tag the marker disappears. Has anyone managed to make it work?

推荐答案

这种情况下你需要加载图片,像这样:

You need to load the image in this case, like this:

:icon="{ url: require('../../assets/img/marker-a.png')}"

示例:

<GmapMarker
  v-for="(m, index) in markers"
  :key="index"
  :ref="`marker${index}`"
  :position="m.position"
  :clickable="true"
  :draggable="true"
  :icon="{ url: require('../../assets/img/marker-a.png')}" />

这篇关于vue2-google-maps 的自定义标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆