Skip to content

Commit

Permalink
Use maplibregl instead of mapboxgl
Browse files Browse the repository at this point in the history
  • Loading branch information
tnagorra committed Nov 9, 2023
1 parent ecb5453 commit 93fd27a
Show file tree
Hide file tree
Showing 15 changed files with 471 additions and 215 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Re-map

React wrapper for Mapboxgl-js
React wrapper for Maplibre
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@togglecorp/re-map",
"version": "0.2.0-beta-5",
"description": "MapboxGL JS wrapper for React",
"description": "Maplibre wrapper for React",
"files": [
"/build"
],
Expand All @@ -10,6 +10,7 @@
"module": "build/esm/index.js",
"typings": "build/esm/index.d.ts",
"scripts": {
"postinstall": "patch-package",
"prepare": "install-peers",
"build": "rm -rf ./build && rollup -c && tsc --project tsconfig-typings.json",
"watch": "rollup -c -w",
Expand All @@ -32,8 +33,8 @@
"@togglecorp/fujs": "^2.1.0"
},
"peerDependencies": {
"@mapbox/mapbox-gl-draw": "^1.2.0",
"mapbox-gl": "^1.13.0",
"@mapbox/mapbox-gl-draw": "^1.4.3",
"maplibre-gl": "^3.5.2",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
Expand All @@ -52,7 +53,7 @@
"@rollup/plugin-commonjs": "^25.0.2",
"@rollup/plugin-eslint": "^9.0.4",
"@rollup/plugin-node-resolve": "^15.1.0",
"@types/mapbox-gl": "^1.13.0",
"@types/mapbox__mapbox-gl-draw": "^1.4.6",
"@types/node": "^20.4.1",
"@types/react": "^17.0.2",
"@types/react-dom": "^17.0.2",
Expand All @@ -68,6 +69,8 @@
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"install-peers-cli": "^2.2.0",
"patch-package": "^8.0.0",
"postinstall-postinstall": "^2.1.0",
"rollup": "^3.26.2",
"rollup-plugin-filesize": "^10.0.0",
"rollup-plugin-progress": "^1.1.2",
Expand Down
78 changes: 78 additions & 0 deletions patches/@types+mapbox__mapbox-gl-draw+1.4.6.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
diff --git a/node_modules/@types/mapbox__mapbox-gl-draw/index.d.ts b/node_modules/@types/mapbox__mapbox-gl-draw/index.d.ts
index 82c47cb..cae557e 100644
--- a/node_modules/@types/mapbox__mapbox-gl-draw/index.d.ts
+++ b/node_modules/@types/mapbox__mapbox-gl-draw/index.d.ts
@@ -1,14 +1,15 @@
import { BBox, Feature, FeatureCollection, GeoJSON, GeoJsonTypes, Geometry, Point, Position } from "geojson";
import {
- CircleLayer,
- FillLayer,
+ CircleLayerSpecification,
+ FillLayerSpecification,
+ LineLayerSpecification,
IControl,
- LineLayer,
+ ControlPosition,
Map,
- MapboxEvent,
+ MapLibreEvent,
MapMouseEvent as MapboxMapMouseEvent,
MapTouchEvent as MapboxMapTouchEvent,
-} from "mapbox-gl";
+} from "maplibre-gl";

export = MapboxDraw;
export as namespace MapboxDraw;
@@ -178,7 +179,7 @@ declare namespace MapboxDraw {
}

interface DrawCustomModeThis {
- map: mapboxgl.Map;
+ map: Map;

drawConfig: MapboxDrawOptions;

@@ -389,13 +390,13 @@ declare namespace MapboxDraw {
isOfMetaType: (
type: Constants["meta"][keyof Constants["meta"]],
) => (e: MapMouseEvent | MapTouchEvent) => boolean;
- isShiftMousedown: (e: MapboxEvent) => boolean;
+ isShiftMousedown: (e: MapLibreEvent) => boolean;
isActiveFeature: (e: MapMouseEvent | MapTouchEvent) => boolean;
isInactiveFeature: (e: MapMouseEvent | MapTouchEvent) => boolean;
noTarget: (e: MapMouseEvent | MapTouchEvent) => boolean;
isFeature: (e: MapMouseEvent | MapTouchEvent) => boolean;
isVertex: (e: MapMouseEvent | MapTouchEvent) => boolean;
- isShiftDown: (e: MapboxEvent) => boolean;
+ isShiftDown: (e: MapLibreEvent) => boolean;
isEscapeKey: (e: KeyboardEvent) => boolean;
isEnterKey: (e: KeyboardEvent) => boolean;
isTrue: () => boolean;
@@ -503,7 +504,7 @@ declare namespace MapboxDraw {

StringSet(items?: Array<string | number>): StringSet;

- theme: Array<(FillLayer | LineLayer | CircleLayer) & { id: ThemeLayerId }>;
+ theme: Array<(FillLayerSpecification | LineLayerSpecification | CircleLayerSpecification) & { id: ThemeLayerId }>;

/**
* Derive a dense array (no `undefined`s) from a single value or array.
@@ -552,7 +553,7 @@ declare class MapboxDraw implements IControl {

modes: MapboxDraw.DrawModes;

- getDefaultPosition: () => string;
+ getDefaultPosition: () => ControlPosition;

constructor(options?: MapboxDraw.MapboxDrawOptions);

@@ -595,7 +596,7 @@ declare class MapboxDraw implements IControl {

setFeatureProperty(featureId: string, property: string, value: any): this;

- onAdd(map: mapboxgl.Map): HTMLElement;
+ onAdd(map: Map): HTMLElement;

- onRemove(map: mapboxgl.Map): any;
+ onRemove(map: Map): any;
}
Loading

0 comments on commit 93fd27a

Please sign in to comment.