openearth / vue2mapbox-gl

Vue components for mapbox-gl. Api follows the approach of Vue2Leaflet so it's easy to port code back and forth between the two map components.
GNU General Public License v3.0
19 stars 8 forks source link

Easy way to create markers? #18

Closed doublemc closed 1 year ago

doublemc commented 4 years ago

Hey, like your lib - first one that actually works out of the box without any problems. I have a problem though - is there a way to add markers via this lib? THx!

SiggyF commented 4 years ago

Thanks. We'll prepare an example in the storybook.

enzoftware commented 4 years ago

any udpate?

claudiomulas-flygo commented 3 years ago

+1

claudiomulas-flygo commented 3 years ago

This is how I've done it:

Captured the event

<v-mapbox @mb-created="mapCreated" />

saved the map variable

mapCreated: function(map){
                console.log("map event", map);
                this.map = map;
            }

and then added the marker import mapboxgl from 'mapbox-gl';

this.point = new mapboxgl.Marker().setLngLat(this.currentPosition).addTo(this.map);

SiggyF commented 1 year ago

This was added in #36