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

Pass Options of enable & enableDraw to addControls #117

Closed
codeofsumit opened this issue Jan 2, 2017 · 4 comments
Closed

Pass Options of enable & enableDraw to addControls #117

codeofsumit opened this issue Jan 2, 2017 · 4 comments
Projects

Comments

@codeofsumit
Copy link
Contributor

As discussed in #116 we need a way to set options of enable and enableDraw for the toolbar buttons as well.

@willvincent
Copy link

This really shouldn't have been closed. This definitely is still an issue.

While you can programmatically call the enable() method and pass options to it, and similarly for enableDraw(), there is not a way to do so in configuration for the toolbar buttons themselves.

#233 added documentation of how to pass options when programatically calling the enableDraw() method. But there is no way I can see, other than reaching into the object after the button has been set visible in the toolbar, to change the behavior or options of edit mode button.

What I found necessary was having to explicitly reach deep into the object and override the afterclick() method of the editMode button's options:

    this.map.pm.Toolbar.buttons.editMode.options.afterClick = () => {
      this.map.pm.toggleGlobalEditMode({
        allowSelfIntersection: false,
        snapDistance: 10,
      });
    };

This is all fine and well, but if this is necessary then instead of just true/false addControls() should allow for passing alternative options to override/combine with the internal defaults at play on the toolbar buttons.

Maybe I missed it in the docs, but it doesn't appear to be possible.

@codeofsumit
Copy link
Contributor Author

Options passed via enableDraw should be preserved for edit mode of the toolbar but nonetheless, I’ll make this a feature request as passing more options in addControls is a good idea. Please upvote

@codeofsumit codeofsumit changed the title Pass Options of enable & enableDraw to Toolbar buttons. Pass Options of enable & enableDraw to addControls Oct 5, 2019
@Falke-Design
Copy link
Collaborator

@codeofsumit can we say that this is now implemented with the new toolbar functions?

@Falke-Design Falke-Design added this to Take a look on in Release 2.8 Oct 6, 2020
@codeofsumit
Copy link
Contributor Author

@willvincent can you confirm that the latest release solves this issue for you?

@codeofsumit codeofsumit moved this from Take a look on to Done in Release 2.8 Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

3 participants