soal / vue-mapbox

Vuejs 2 components for interacting with mapbox-gl-js
https://soal.github.io/vue-mapbox
MIT License
474 stars 147 forks source link

Setting a layout on addLayer is ignored #231

Open tb4764 opened 3 years ago

tb4764 commented 3 years ago

I'm trying to add a GeoJson source and a symbol layer with some layout properties. The source and layer are added, but the layout options are not implemented.

map.addSource('newSource', {
        'type': 'geojson',
        'data': {
              "type": "FeatureCollection",
              "features": [
                    {
                           "type": "Feature",
                           "geometry": { "type": "Point", "coordinates": [0, 0] },
                    }
              ]
        }
})
map.addLayer({
            'id': 'newLayer',
            'type': 'symbol',
            'source': 'newSource',
            'layout': {
                'icon-image': 'arrow',
                'icon-size': 10
            }
        })

When I track the map layers (map.getStyle().layers) in the console, the added layer only has the following:

id: "newLayer"
source: "newSource"
type: "symbol"

I tried this in a simple HTML file (without Vue & vue-maxpbox), and it works fine (ie, the layout properties are applied and visible in the console). Any idea?