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

How to access the "Static" mode. #257

Open
lgspacil opened this issue Jan 27, 2021 · 1 comment
Open

How to access the "Static" mode. #257

lgspacil opened this issue Jan 27, 2021 · 1 comment

Comments

@lgspacil
Copy link

I noticed there is a Static mode available but I am unable to change into it through the changeMode method. Is there a way to access the static mode since I want to turn off editing of shapes at some point for the user. Thanks!

@BlastWind
Copy link

BlastWind commented Jun 18, 2021

Hey, I don't think Static mode is available by default. You can make custom modes, and someone (main maintainer of mapbox-gl) happened to have open sourced a static custom mode here: https://github.com/mapbox/mapbox-gl-draw-static-mode.
Static mode is easy to implement on your own though, here's a code snippet that should work:

StaticMode.onSetup = function () {
  this.setActionableState(); // default actionable state is false for all actions
  return {};
};

StaticMode.toDisplayFeatures = function (state, geojson, display) {
  display(geojson);
};

// in your component: 
<DrawControl mode={{static: StaticMode}} defaultMode={"static"}/ >

You probably would want the DrawControl to have more than just the static mode though. I'm sure you can figure that part out on your own.

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