I took this demo from mapbox:
https://docs.mapbox.com/mapbox-gl-js/example/hover-styles/
I put in my own GeoJson file in replacement of the demo one, the code is here:
https://codepen.io/hiven/pen/rNYdvdg?editors=1112
The error I get is:
Error: The feature id parameter must be provided.
I can't understand what this is saying, as a feature ID is provided here in this snippet:
map.addLayer({
'id': 'state-borders',
'type': 'line',
'source': 'states',
'layout': {},
'paint': {
'line-color': '#627BC1',
'line-width': 2
}
});
You have to add generateId: true to your addSource method params.
map.addSource('states', {
'type': 'geojson',
'data': 'https://hiven.github.io/map2/hexagons.geojson',
'generateId': true //This ensures that all features have unique IDs
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With