Skip to content

Commit

Permalink
Updated constants & style imports
Browse files Browse the repository at this point in the history
  • Loading branch information
KhaledMohamedP committed Dec 6, 2024
1 parent 23d50ec commit b29799a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
6 changes: 2 additions & 4 deletions demo/src/App.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -90,12 +88,12 @@ function App() {
};
},
});

draw = new MapboxDraw({
modes: {
...CutPolygonMode(MapboxDraw.modes),
},
styles: [...splitPolygonDrawStyles(defaultDrawStyle)],
styles: [...splitPolygonDrawStyles(MapboxDraw.lib.theme)],
userProperties: true,
});

Expand Down
15 changes: 5 additions & 10 deletions src/mode.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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(),
});
};
Expand Down

0 comments on commit b29799a

Please sign in to comment.