- cdf5c1d: fix: fixed bug of angled-rectangle, sensor and sector SVG icons which were not rotated with transform in some browser.
- 37a9836: fix: fixed bug when render button is removed. add default hidden mode if no render buttom.
- fa9ec0f: call this.deactivate() when calling map.removeControl(drawControl)
-
2e23ac1: feat: add
delete-selection
mode to allow users to delete only selected feature. Newdelete-selection
mode is enabled whenselect
mode is chosen. As default, it appears right afterselect
mode, but you can change it in constructor.const drawControl = new MaplibreTerradrawControl({ modes: [ 'render', 'select', 'delete-selection', // place `delete-selection` after select mode. Or you can delete it if this feature is not needed. 'point', 'delete' ], open: true }); map.addControl(drawControl, 'top-left');
- ec05a90: call TerraDraw.stop() when calling onRemove()
- c8742be: feat: added Sensor mode and Sector mode to the plugin.
- c4e42ff: remove controlContrainer on map.removeControl(drawControl)
-
bc8d9c3: feat: add 'delete' mode to arrow users to show/hide delete button in prefered order.
const drawControl = new MaplibreTerradrawControl({ modes: [ 'render', 'select', 'point', 'delete' // delete mode must be specified to show delete button in the tool ], open: true }); map.addControl(drawControl, 'top-left');
-
bf466fb: feat: add 'render' mode in default control options in constructor. Now, the position of render toggle mode button can be changed, or completely remove it from control to keep tool always open.
const drawControl = new MaplibreTerradrawControl({ modes: [ 'render', // delete this if you want the tool to be always opened. 'select', 'point' ], open: true // if you remove 'render' mode, make sure setting open as true. }); map.addControl(drawControl, 'top-left');
- aac04eb: fix: show tooltip for each button.
- 0a6130e: fix: fixed bug of angled-rectangle icon in active state. Rotate 45 degree of SVG itself.
- d1633d4: fix: added rotateable and scalable for linestring.
-
1935d2c: refactor: removed unused variable from the code
-
5c56e28: fix: merge modeOptions param into the first argument of constructor to make the interface simple.
In v0.1.0, it used the second argument of constructor to customise drawing options for each Terra Draw mode. The second argment was now merged into the first argument as shown in the below sample code.
const drawControl = new MaplibreTerradrawControl({ // only show polgyon, line and select mode. modes: ['polygon', 'linestring', 'select'], modeOptions: { select: new TerraDrawSelectMode({ flags: { // only update polygon settings for select mode. // default settings will be used for other geometry types // in this case, line uses default options of the plugin. polygon: { feature: { draggable: false, // users cannot drag to move polygon rotateable: true, scaleable: true, coordinates: { midpoints: false, // users cannot add a node on the middle of edge. draggable: true, deletable: false // users cannot delete a node. } } } } }) } }); map.addControl(drawControl, 'top-left');
-
4d9a435: feat: allows to overwrite default Terra Draw mode instances by using the second argument of constructor.
For example, if you only want to use polygon control, and you want to disable draggable option and node insertion/deletion on an edge of a polygon, the setting can be as follows.
const drawControl = new MaplibreTerradrawControl( { modes: ['polygon', 'select'] }, { select: new TerraDrawSelectMode({ flags: { polygon: { feature: { draggable: false, // users cannot drag to move polygon rotateable: true, scaleable: true, coordinates: { midpoints: false, // users cannot add a node on the middle of edge. draggable: true, deletable: false // users cannot delete a node. } } } } }) } ); map.addControl(drawControl, 'top-left');
-
4d9a435: feat: allows to change the order of Terra Draw modes on the plugin.
Now, an array of modes can be passed to the constructor of the plugin, and the mode controls will be added exactly the same order. You can also remove unnecessary modes from the array when you initialize the plugin.
For instance, you can only add point and select control on the plugin like the below code.
const drawControl = new MaplibreTerradrawControl({ modes: ['point', 'select'] }); map.addControl(drawControl, 'top-left');
- 0d9c15e: fix: updated peerDependencies in package.json to support maplibre v2 to v4 since terra-draw is supporting maplibre from v2
-
8ec1f8c: feat: added
open
option in the control constructor. Default is false. If true is set toopen
option, editor controller will be expaned as default.To expand control as default, create control instance like below.
const drawControl = new MaplibreTerradrawControl({ open: true });
- 069bd2e: fix: moved maplibre-gl and terra-draw to peerDependencies. and updated all other dependencies.
- bfe061e: fix: added TerraDrawRenderMode control as 'render' mode, and it will be used as default state.
- bbd65a7: fix: added index.d.ts and fixed package.json