watergis / maplibre-gl-terradraw

This plugin is to add controls to your maplibre for sketching powered by terradraw library.
https://terradraw.water-gis.com/
MIT License
16 stars 1 forks source link

fix: merge modeOptions param into the first argument of constructor to make the interface simple. #20

Closed JinIgarashi closed 1 month ago

JinIgarashi commented 1 month ago

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');
changeset-bot[bot] commented 1 month ago

🦋 Changeset detected

Latest commit: ca41145cadf4ad487547fa4cf3ea99a05889a0d3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ------------------------------- | ----- | | @watergis/maplibre-gl-terradraw | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

netlify[bot] commented 1 month ago

Deploy Preview for maplibre-gl-terradraw ready!

Name Link
Latest commit ca41145cadf4ad487547fa4cf3ea99a05889a0d3
Latest deploy log https://app.netlify.com/sites/maplibre-gl-terradraw/deploys/66dd668acadbfe000868ab57
Deploy Preview https://deploy-preview-20--maplibre-gl-terradraw.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.