mapbox / mapbox-gl-draw

Draw tools for mapbox-gl-js
https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-draw/
ISC License
953 stars 593 forks source link

MapboxDraw is not a constructor #1014

Open csimpi opened 4 years ago

csimpi commented 4 years ago

mapbox-gl-js version: 1.12.0 mapbox-gl-draw version: 1.2.0

Framework: Angular 9

Steps to Trigger Behavior

  1. Install
  2. Import
  3. Start Angular App

Expected Behavior

Loads and works

Actual Behavior

I'm getting several error messages and it doesn't even load at all.

I saw some suggestions to change angular.json file or using old versions but those feel very ugly workarounds for me.

jfoshee commented 3 years ago

What does your import look like? With 1.2.0 I see they switched to ES6 style modules. I believe the following

import * as MapboxDraw from '@mapbox/mapbox-gl-draw';

should be changed to

import MapboxDraw from '@mapbox/mapbox-gl-draw';

However matters may be more complicated if you rolled your own type definitions. I haven't figured that out yet.

csimpi commented 3 years ago

@jfoshee Thank you!

I don't even remember what was this. I guess I've solved it on my own. Mapbox support is super bad, unfortunately. They are not lazy only when they're sending the USD 2000 invoice per month :) I have never got proper support to my issues not here, not at the official support.

Souvik-Khan31 commented 1 year ago

Try With this--->>>

import as mapboxgl from 'mapbox-gl'; import as MapboxDraw from "@mapbox/mapbox-gl-draw";

  this.mapDraw = new MapboxDraw.default({
      displayControlsDefault: false,
      controls: {
        polygon: false,
        line_string: false,
        point: true,
        trash: true
      },
      defaultMode: 'draw_point'
    });

It will work definately..For me working with angular 15.... By using '.default'