mapbox / mapbox/mapbox-gl-js

Map#setLayerSource to allow changing a layer's source

Open
#6,895 1 comment 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

This would let you change a layer's source. Currently you need to

  1. getLayer (due to #3713 you need to getStyle then find the layer)
  2. removeLayer
  3. addLayer

This would make it easier to to use local GeoJSON sources on the client side together with layers from Mapbox Studio. In Studio you can't create local GeoJSON source layers so you need to use a dummy source, which requires swapping out on the client side.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Map#setLayerSource entry point and compare the existing getLayer/getStyle, removeLayer, and addLayer flow described in the issue. Determine how a layer can switch from a Studio dummy source to a client-side GeoJSON source without that sequence. Done means the public Map API supports changing the layer source while preserving the layer, with coverage for the described use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.