Skip to content

Custom mode for Mapbox GL Draw that adds the functionality to draw rectangles

Notifications You must be signed in to change notification settings

teamookla/mapbox-gl-draw-rectangle-mode

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mapbox GL Draw Rectangle Mode

A custom mode for MapboxGL Draw to draw rectangles that adds the functionality of keeping the rectangle's shape when adjusting a corner of the drawn rectangles. This mode is compatible with @mapbox/mapbox-gl-draw@1.4.0 and above. Original inspiration comes from this package, which hasn't been mantained for the last 4 years: https://github.com/thegisdev/mapbox-gl-draw-rectangle-mode

Usage

import DrawRectangle from 'mapbox-gl-draw-rectangle-mode';

const modes = MapboxDraw.modes;
modes.draw_rectangle = DrawRectangle;

const draw = new MapboxDraw({
  modes: modes
});

draw.changeMode('draw_rectangle');

Once a rectangle is created, 1 event is fired:

  • draw.create with the created rectangle

Build

yarn build will do it.

License

MIT

About

Custom mode for Mapbox GL Draw that adds the functionality to draw rectangles

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%