mapbox-gl-draw icon indicating copy to clipboard operation
mapbox-gl-draw copied to clipboard

map.removeControl(draw); throws an error

Open donnyv opened this issue 5 years ago • 3 comments

It seems when trying to remove the control using map.removeControl(draw); it throws an error. I think removeControl() is not properly implemented.

donnyv avatar Jan 02 '20 13:01 donnyv

I've got that error too

just need to know if this is going to be solved

Uncaught TypeError: can't access property "off", e.map is undefined

where 'map' is my mapbox instance

fabrusso avatar Mar 03 '23 12:03 fabrusso

Any update regarding this? This issue is still persisted till now. Using react-map-gl, I am attempting to remove draw when it unmounts but I get the error can't access property "off".

useEffect(() => {
 if (!map) return;

 map.addControl(...)

 return () => {
  map.removeControl(...) // throws error
 }
}, [map])

This is really proving to be a nuisance as my current method is to completely reload the map between navigations which means higher API usage cc @kkaefer

ShafSpecs avatar Mar 09 '24 16:03 ShafSpecs

Noticed this too.

lochstar avatar Mar 18 '24 02:03 lochstar