Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save guy-kdm/a6e93c190b267582f1d859e08ef0df5f to your computer and use it in GitHub Desktop.
Save guy-kdm/a6e93c190b267582f1d859e08ef0df5f to your computer and use it in GitHub Desktop.
const map = new mapboxgl.Map(mergedOptions)
map.on("style.load", function () {
map.setFilter("layer-with-polygons", [
"==",
["get", "City"],
"Budapest",
])
})
map.on("load", () => {
let features = map.querySourceFeatures("composite", {
sourceLayer: "layer-with-polygons",
})
let bounds = new mapboxgl.LngLatBounds()
features.forEach((feature) =>
// @ts-ignore
feature.geometry.coordinates.flat().forEach((cord: any) => bounds.extend(cord))
)
map.fitBounds(bounds)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment