Search code examples
vue.jsvue2-google-maps

custom marker for vue2-google-maps


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?


Solution

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

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

    An example:

    <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')}" />