Skip to content

Instantly share code, notes, and snippets.

@ostermanj
Created August 15, 2022 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ostermanj/c8302e49e9b83b83a05bd2e964d92fba to your computer and use it in GitHub Desktop.
Save ostermanj/c8302e49e9b83b83a05bd2e964d92fba to your computer and use it in GitHub Desktop.
mbHelper addSourceAndLayers() example
mbHelper.addSourceAndLayers.call(map,
{ // source
"type": "vector",
"url": "mapbox://mapbox.us_census_states_2015",
"name": "states"
}, [ // layers
{ // layer one
"id": "states-join",
"type": "fill",
"source-layer": 'states',
"paint": {
"fill-color": 'transparent'
},
"beforeLayer": "water" // <== this is different from mapbox native specs
},
{ // layer two
"id": "states-join-hover",
"type": "line",
"source-layer": 'states',
"paint": {
"line-color": '#4D90FE',
"line-width": 4,
"line-blur": 2
},
"filter": ["==", "name", ""]
}
]).then(() => {
// do some stuff
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment