studiometa / vue-mapbox-gl

🗺 Vue components for mapbox-gl
https://vue-mapbox-gl.studiometa.dev
133 stars 38 forks source link

Add an exemple on how to load a custom marker image for the StoreLocator component #40

Open perruche opened 3 years ago

perruche commented 3 years ago

Add a section on the documentation on "how to load a custom marker image for the StoreLocator component"

Add the important details:

Code:

<template>
    <store-locator
      :items="items"
      :mapbox-cluster="{
        'unclustered-point-layer-type': 'circle',
        'unclustered-point-layer-type': 'symbol',
        'unclustered-point-layout': {
          'icon-image': 'pin',
          'icon-size': 1
        },
        'unclustered-point-paint': {},
      }"
      access-token="..."
      :mapbox-map="{
        mapStyle: '...',
        center: [ 2.0, 48.0 ],
        zoom: 1,
      }"
      @map-created="onMapCreated">
      <!-- template -->
    </store-locator>
</template>

<script>
  export default {
    props: {
      items: {
        type: Array,
        required: true,
      },
   },
    methods: {
      onMapCreated(map) {
       const imgPath = 'imag.png';
        map.loadImage(imagePath, (error, image) => {
          if (error) { throw error; }
          map.addImage('pin', image);
        });
      },
    },
  };
</script>
M-GRV commented 3 weeks ago

Please add this to the docs! We thought it wasn't supported until we saw this issue!