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

Provide a setter and getter method for map.interactive #5232

Closed
indus opened this issue Sep 1, 2017 · 4 comments
Closed

Provide a setter and getter method for map.interactive #5232

indus opened this issue Sep 1, 2017 · 4 comments
Labels

Comments

@indus
Copy link
Contributor

indus commented Sep 1, 2017

Motivation

At the moment the property "interactive" of map can only be set at the beginning and you can't turn it on and of during the lifetime of the map instance. I want to disable map interactivity during "flyto" activity to be sure that the map is at the correct spot at the "moveend" event. Userinterction during the flight would stop the animation and result in a "moveend" at a different location.

Design Alternatives

"Do nothing" is an option because it is possible to disable all Interaction-Handlers on "movestart" and re-enable them on "moveend" (but it is cumbersome to do, especially if you have to keep track of what was turned on before to come to the same setting afterwards). Could look like:

const MAP_HANDLER = ["boxZoom", "scrollZoom", "dragPan", ...];
function setInteractivity (val) {
  val = val ? 'enable' : 'disable';
  MAP_HANDLER.forEach((h) => (h = map[h]) && h.enable && h.disable && h[val]())
}

Design

Provide a method "setInteractivity(true/false)" (and a corresponding getter-method as well) to toggle the interactivity of the map. This value would be used to override the enabled/disabled state of all the handlers without changing it.

Mock-Up

for my case:

map.flyTo({ center: [0,0], zoom:0})
.once('movestart', ev => {
  map.setInteractivity(false)
  // drop all user interaction from here
})
.once('movend', ev => {
  //be dead certain to have the map centered at global scale
  map.setInteractivity(true);
  //map is interactive again
})

Concepts

What existing precedents support the new concepts?

other Map-Options have getter and setter methods as well

Implementation

How you would implement the design in Javascript?

All InteractionHandlers check for the global interactivity property on their corresponding map and drop events if it is set to false

@indus indus changed the title make interactivity of map togglable provide a setter- and getter method for map.interactive Sep 1, 2017
@indus indus changed the title provide a setter- and getter method for map.interactive Provide a setter and getter method for map.interactive Sep 1, 2017
@anandthakker
Copy link
Contributor

Thanks @indus, I agree that it makes sense to have a getter/setter for this option.

@indus
Copy link
Contributor Author

indus commented Sep 13, 2017

Sounds like #4029 will take care of it.

@indus indus closed this as completed Sep 13, 2017
@bruno-vaz
Copy link

#4029 is still open as of today, is there a way to dynamically disable/enable all interactivity on the map?

@Erutan409
Copy link

Erutan409 commented Dec 11, 2018

@bruno-vaz I ended up creating an absolutely positioned div with a higher z-index on the map. If I wanted to disable interactivity, I'd just show the element. I connected it to an overloaded property on the map instance that when toggled (bit flag variable), it would use a defined setter to set the aforementioned element's visibility.

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

No branches or pull requests

4 participants