visgl / visgl/react-map-gl

[Feat] Give map instance as input

Open
#2,575 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
TypeScript
Stars
8.5k
Forks
1.4k
Avg merge
5d 17h
Merged PRs (30d)
3

Description

Target Use Case

I have an instance of mapbox already being used in my app and when I was on an older version of react-map-gl I was create a context with the map instance and still using the Layer and Source components as normal.

After the upgrade I can't do this anymore so in my case where I have part of my app not written in React and part of it using React, I can't extend my existing map using react-map-gl as I was before.

Example:

<MapContext.Provider
      value={{
        map: {
          getMap: () => map,
        } as any,
        mapLib: mapboxgl as MapboxAsMapLib,
      }}
    >
.....

Where map was a prop of my component.

Proposal

Since I can't override the context anymore, it would be nice if the main Map component could receive an existing external map instance as an option

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 by reading the main Map component and MapContext, especially how the existing map and mapLib values are provided to Layer and Source. Determine the API and lifecycle requirements for accepting an external map instance, then verify that an existing non-React map can be extended with the React components without breaking normal Map usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.