From b29799a0a6d5d648f06cee23f59b67c08bb43d68 Mon Sep 17 00:00:00 2001 From: KhaledMohamedP Date: Fri, 6 Dec 2024 18:37:56 -0500 Subject: [PATCH] Updated constants & style imports --- demo/src/App.js | 6 ++---- src/mode.js | 15 +++++---------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/demo/src/App.js b/demo/src/App.js index 0045589..ab3103a 100644 --- a/demo/src/App.js +++ b/demo/src/App.js @@ -1,8 +1,6 @@ import React, { useRef, useEffect } from "react"; import mapboxGl from "mapbox-gl"; import MapboxDraw from "@mapbox/mapbox-gl-draw"; -import defaultDrawStyle from "@mapbox/mapbox-gl-draw/src/lib/theme"; - import CutPolygonMode, { drawStyles as splitPolygonDrawStyles, } from "mapbox-gl-draw-cut-polygon-mode"; @@ -90,12 +88,12 @@ function App() { }; }, }); - + draw = new MapboxDraw({ modes: { ...CutPolygonMode(MapboxDraw.modes), }, - styles: [...splitPolygonDrawStyles(defaultDrawStyle)], + styles: [...splitPolygonDrawStyles(MapboxDraw.lib.theme)], userProperties: true, }); diff --git a/src/mode.js b/src/mode.js index 27c7df6..9503009 100644 --- a/src/mode.js +++ b/src/mode.js @@ -1,9 +1,4 @@ -import { - geojsonTypes, - updateActions, - events, -} from "@mapbox/mapbox-gl-draw/src/constants"; - +import {constants} from "@mapbox/mapbox-gl-draw"; import difference from "@turf/difference"; import { @@ -36,8 +31,8 @@ CutPolygonMode.onSetup = function (opt) { onDraw: (cuttingpolygon) => { main.forEach((feature) => { if ( - feature.geometry.type === geojsonTypes.POLYGON || - feature.geometry.type === geojsonTypes.MULTI_POLYGON + feature.geometry.type === constants.geojsonTypes.POLYGON || + feature.geometry.type === constants.geojsonTypes.MULTI_POLYGON ) { const afterCut = difference(feature, cuttingpolygon); const newF = this.newFeature(afterCut); @@ -70,8 +65,8 @@ CutPolygonMode.toDisplayFeatures = function (state, geojson, display) { }; CutPolygonMode.fireUpdate = function (newF) { - this.map.fire(events.UPDATE, { - action: updateActions.CHANGE_COORDINATES, + this.map.fire(constants.events.UPDATE, { + action: constants.updateActions.CHANGE_COORDINATES, features: newF.toGeoJSON(), }); };