Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
perruche opened this issue Jul 13, 2021 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@perruche
Copy link
Contributor

perruche commented Jul 13, 2021

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

Add the important details:

  • image must be png
  • Adapt icon-size param if you load a png in size 2x or 3x
  • icon-image param must use the same name as in addImage fn

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>
@perruche perruche added documentation Improvements or additions to documentation enhancement New feature or request labels Jul 13, 2021
@perruche perruche self-assigned this Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant