mapbox / mapbox-gl-draw

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

MapboxDraw.modes is undefined #683

Open cyrilchapon opened 7 years ago

cyrilchapon commented 7 years ago

mapbox-gl-js version: v0.39.1 mapbox-gl-draw version: v0.19.0

Steps to Trigger Behavior

  1. console.log(MapboxDraw.modes)

Expected Behavior

API states that

modes, Object: over ride the default modes with your own. MapboxDraw.modes can be used to see the default values

Actual Behavior

MapboxDraw.modes is undefined

Side notes

I'm using both mapboxgl and mapboxgldraw from a CDN in the browser, using globals from window

cyrilchapon commented 7 years ago

Workaround : Instanciate a temporary object

(new MapboxDraw()).modes

and use it to instanciate the real MapboxDraw object

var modes = (new MapboxDraw()).modes;
modes.MYCUSTOMMODE = MyCustomMode;
var draw = new MapboxDraw({
  modes: modes
});
mcwhittemore commented 7 years ago

MapboxDraw.modes should be ./src/modes/index.js while api.modes is the Modes constants object. Part of me wants to drop api.modes along with a fix for this to help mitigate confusion about what these two values indicate.

cyrilchapon commented 7 years ago

Agreed, furthermore js convention for uppercase is prototype I think, while lowercased camel for instances, isn't it ?

Envoyé de mon iPhone

Le 29 août 2017 à 17:49, Matthew Chase Whittemore notifications@github.com<mailto:notifications@github.com> a écrit :

MapboxDraw.modes should be ./src/modes/index.js while api.modes is the Modes constants object. Part of me wants to drop api.modes along with a fix for this to help mitigate confusion about what these two values indicate.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/mapbox/mapbox-gl-draw/issues/683#issuecomment-325707659, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKOz6sdLwCswy7K4Gw99foc1nxNuwexYks5sdDMYgaJpZM4PFpz7.

mcwhittemore commented 7 years ago

I'm not sure what you're asking @cyrilchapon. Can you provide an example?

pedrobarquinha commented 4 years ago

Hey there! @mcwhittemore was this ever fixed? I'm still getting this as undefined and have been unable to add custom modes on the most recent release.

Because of this issue, the instructions provided at https://github.com/mapbox/mapbox-gl-draw/blob/master/docs/MODES.md don't work.