mapbox / mapbox/mapbox-gl-js

Refactor "GeoJSONSource" as a composition "VectorTileSource"

Open
#3,051 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

See the instructions in [this comment](https://github.com/mapbox/mapbox-gl-js/pull/2918#issuecomment-241714024) for a description of what would currently be required to create a custom variation of `VectorTileSource`.

On the worker side, it's not bad at all: `VectorTileWorkerSource` is designed to accept a custom `loadVectorTile` in its constructor. But on the main thread, the whole `VectorTileSource` has to be forked in order to add a `type: 'my-custom-source-type-name'` property to any params sent to the worker (so that messages go to the custom worker source rather than the core VectorTileWorkerSource).

If `VectorTileSource` just kept a `this.type` property from its constructor options and sent it along in all its worker requests, this would simplify a custom source author's job significantly.

cc @lucaswoj

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 with the linked pull request comment, then inspect VectorTileSource and VectorTileWorkerSource to understand how worker requests select a source. The refactor is complete when a custom source can provide its type through worker requests without forking VectorTileSource; identify or add coverage for that behavior if the existing tests expose these entry points.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Refactor
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.