Q-bart
Q-bart

Reputation: 1591

Mapbox: auto fly to added source

How to force mapbox to fly to the source after it was added?

For Example, I add a new geojson source:

map.addSource('some-id', {
    type: 'geojson',
    data: 'https://some.url/data.geojson',
});

When I try to querySourceFeatures right after this, it returns nothing:

map.querySourceFeatures('some-id')

How to do this in a correct way?

Upvotes: 0

Views: 258

Answers (1)

AndrewHarvey
AndrewHarvey

Reputation: 3055

You'll probably need to download your GeoJSON with fetch etc first then look through to find the bbox then fitBounds.

Upvotes: 1

Related Questions