Skip to content

Commit b67ccd6

Browse files
committed
upgrade react-map-gl
1 parent 8a81646 commit b67ccd6

33 files changed

Lines changed: 325 additions & 197 deletions

.env.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_MAPBOX_TOKEN=add-your-mapbox-key

example-mapbox/.env.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VITE_MAPBOX_KEY=add-your-mapbox-key
1+
VITE_MAPBOX_TOKEN=add-your-mapbox-key

example-mapbox/src/canvas.basic.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const Box: FC<{ position: Vector3 }> = (props) => {
3838

3939
export function BasicExample() {
4040

41-
const { mapboxToken } = useControls({ mapboxToken: import.meta.env.VITE_MAPBOX_KEY || '' })
41+
const { mapboxToken } = useControls({ mapboxToken: import.meta.env.VITE_MAPBOX_TOKEN || '' })
4242

4343
Mapbox.accessToken = mapboxToken;
4444

example-mapbox/src/story-map.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const StoryMap: FC<StoryMapProps> = ({
1717
latitude, longitude, zoom = 18, pitch = 60, children
1818
}) => {
1919

20-
const { mapboxToken } = useControls({ mapboxToken: import.meta.env.VITE_MAPBOX_KEY || '' })
20+
const { mapboxToken } = useControls({ mapboxToken: import.meta.env.VITE_MAPBOX_TOKEN || '' })
2121

2222
const theme = useLadleContext().globalState.theme;
2323

maplibre/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"internal": true,
33
"main": "../dist/maplibre/cjs/main.js",
44
"module": "../dist/maplibre/es/main.js",
5-
"types": "../src/main-maplibre.ts",
5+
"types": "../src/maplibre/index.ts",
66
"sideEffects": false
77
}

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Use react-three-fiber inside MapLibre and Mapbox",
55
"main": "dist/cjs/main.js",
66
"module": "dist/es/main.js",
7-
"types": "src/main-mapbox.ts",
7+
"types": "src/mapbox/index.ts",
88
"sideEffects": false,
99
"repository": "https://github.com/RodrigoHamuy/react-three-map",
1010
"homepage": "https://github.com/RodrigoHamuy/react-three-map",
@@ -14,7 +14,6 @@
1414
"license": "MIT",
1515
"author": "RodrigoHamuy",
1616
"scripts": {
17-
"dev": "vite",
1817
"prebuild": "tsc",
1918
"build": "yarn build:maplibre && yarn build:mapbox",
2019
"build:maplibre": "cross-env LIB_MODE=1 MAP_MODE=0 vite build",
@@ -33,7 +32,7 @@
3332
"@changesets/cli": "^2.26.1",
3433
"@ladle/react": "^2.13.0",
3534
"@react-three/drei": "^9.74.5",
36-
"@react-three/fiber": "^8.13.3",
35+
"@react-three/fiber": "^8.13.4",
3736
"@types/node": "^20.3.1",
3837
"@types/react": "^18.0.37",
3938
"@types/react-dom": "^18.0.11",
@@ -50,10 +49,14 @@
5049
"maplibre-gl": "^3.1.0",
5150
"react": "^18.2.0",
5251
"react-dom": "^18.2.0",
53-
"react-map-gl": "^7.0.25",
52+
"react-map-gl": "^7.1.0",
5453
"three": "^0.153.0",
5554
"three-stdlib": "^2.23.8",
5655
"typescript": "~5.0.2",
5756
"vite": "^4.3.9"
57+
},
58+
"peerDependencies": {
59+
"@react-three/fiber": "^8.13.4",
60+
"react-map-gl": "^7.1.0"
5861
}
5962
}
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
// mock of functions used by `react-three-map` from `Maplibre` or `Mapbox`
22

3+
/** Generic interface of Mapbox/Maplibre `LayerProps` */
4+
export interface LayerProps {
5+
id: string;
6+
type: 'custom';
7+
renderingMode: '3d';
8+
onRemove?(map: MapInstance, gl: WebGLRenderingContext): void;
9+
onAdd?(map: MapInstance, gl: WebGLRenderingContext): void;
10+
prerender?(gl: WebGLRenderingContext, matrix: number[]): void;
11+
render(gl: WebGLRenderingContext, matrix: number[]): void;
12+
}
13+
314
/** Generic interface of Mapbox/Maplibre `LngLatLike` */
415
export type LngLatLike = {
516
lng: number;
@@ -24,7 +35,7 @@ export interface MercatorCoordinate {
2435
}
2536

2637
/** Generic interface of Mapbox/Maplibre `Map` */
27-
export interface Map {
38+
export interface MapInstance {
2839
getCanvas(): HTMLCanvasElement;
2940
triggerRepaint(): void;
3041
// eslint-disable-next-line @typescript-eslint/ban-types
@@ -41,6 +52,6 @@ export type MapEventType = {
4152
/** Generic interface of `MapLibreEvent` or `MapBoxEvent` */
4253
export interface MapEvent<TOrig = unknown> {
4354
type: string;
44-
target: Map;
55+
target: MapInstance;
4556
originalEvent: TOrig;
4657
}

0 commit comments

Comments
 (0)