[Feat] Give map instance as input

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

Nobody has claimed this yet.

Assessment

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

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.

Description

feature
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

Dominant language
TypeScript
Stars
8.5k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Getting set up

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.

More from visgl/react-map-gl

All issues in visgl/react-map-gl

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.