Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circle Radius Change with Input #39

Open
furkanbezci opened this issue Jun 8, 2021 · 1 comment
Open

Circle Radius Change with Input #39

furkanbezci opened this issue Jun 8, 2021 · 1 comment

Comments

@furkanbezci
Copy link

I want to change radius of circle by inputting value. Is it posssible and how can I do this? Thank you! (I use mapboxgl)

@cai30304
Copy link

you can try to use draw.set, this can update all draw feature.

my idea is get the all draw, and change someone's feature by id, then set.

below code is example write by vue.js

changeCircleRadius: function (event, draw_layer) {
            const allDraw = this.draw.getAll();
            const id = draw_layer.id;
            const center = draw_layer.center;
            const newRadius = event.currentTarget.value;
            const circle = require('@turf/circle').default;
            const circleFeature = circle(center, newRadius);

            allDraw.features.forEach(feature => {
                if(feature.id == id){
                    feature.geometry.coordinates = circleFeature.geometry.coordinates;
                    feature.properties.radiusInKm = newRadius;
                }
            });

            this.draw.set(allDraw);
        },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants