ReyhaneMasumi / mapbox-gl-draw-cut-polygon-mode

A custom mode for MapboxGL Draw to cut polygons
MIT License
17 stars 5 forks source link

Update to be compatible with the latest mapbox versions #8

Open martenjurgens opened 5 months ago

martenjurgens commented 5 months ago

Hello,

Could this please be updated to be compatible with the latest versions of mapbox-gl, @mapbox/mapbox-gl-draw and mapbox-gl-draw-passing-mode?

Thank you

tiagolr commented 4 months ago

+1 Currently bumping into: ERROR: Could not resolve "@mapbox/mapbox-gl-draw/src/constants Tried downgrading mapbox-gl-draw to same version used in demo, a different error pops, can you update this library? Many thanks

tiagolr commented 4 months ago

Was able to fix this by importing cut-polygon-mode into my project and replacing the constants import in mode.js with:

const geojsonTypes = MapboxDraw.constants.geojsonTypes
const updateActions = MapboxDraw.constants.updateActions
const events = MapboxDraw.constants.events
vsidamonidze commented 3 months ago

If you're using Vite or webpack you could set an alias in the config:

// vite.config.ts

export default defineConfig({
  resolve: {
    alias: {
      "@mapbox/mapbox-gl-draw/src/constants": resolve(__dirname, "patch.ts"),
    },
  },
});
// patch.ts

import { constants } from "@mapbox/mapbox-gl-draw";

const { events, geojsonTypes, updateActions } = constants;

export { events, geojsonTypes, updateActions };