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

User-initiated zoom events? #2934

Open
geleto opened this issue Oct 6, 2014 · 12 comments · May be fixed by #6929
Open

User-initiated zoom events? #2934

geleto opened this issue Oct 6, 2014 · 12 comments · May be fixed by #6929
Labels

Comments

@geleto
Copy link

geleto commented Oct 6, 2014

Hello,
It seems that leaflet has no specific event, which is triggered when the user zooms the map, but not when the zoom level was changed programmatically.
Maybe dragstart should be triggered when pinch-zooming because this usually changes the map position too.
I use the leaflet-locatecontrol and I need to stop tracking the user movements when he drags or pinch-zooms the map.

@mourner mourner added the feature label Nov 6, 2014
@mourner mourner added this to the undecided milestone Nov 6, 2014
@mourner mourner added the later label Nov 26, 2014
@Grsmto
Copy link

Grsmto commented Jun 7, 2015

While creating a custom layer I found myself having to hack the lib to have access to zoom events.
I needed to know to which zoom level the map was animating, zoom property is updated only on zoomend event, which is too late if you want to animate anything custom at the same time as the map animation.
If anyone is interested by my solution, what I did is firing a zoom event:
this.fire('zoom', {zoom: zoom}); in setZoom() and setZoomAround() functions from L.Map.

Can be related to #3269

@dmitry
Copy link

dmitry commented Jul 27, 2015

I have the same situation, when I need to prevent from invoking fitBounds while user interacts with the map. Looks like it could be fixed while #3278, but it's already was merged. I believe it could be named something like triggerSource with values user and program, or just a boolean triggeredByUser.

@dmitry
Copy link

dmitry commented Jul 28, 2015

Additional information, but related to the google maps: http://stackoverflow.com/questions/10097647/how-to-listen-for-user-generated-zoom-in-google-maps

@dmitry
Copy link

dmitry commented Jul 28, 2015

Just for anyone, who stuck with the same issue, here are the approach I've used in the project:

  onDragEnd() {
    this.onUserChange();
  },
  onZoomEnd() {
    if (this.isUser) {
      this.onUserChange();
    }
  },
  onMoveEnd() {
    this.isUser = true;
  },

bindings:

    this.map.on('dragend', this.onDragEnd);
    this.map.on('zoomend', this.onZoomEnd);
    this.map.on('moveend', this.onMoveEnd);

Would be nice to replace onMoveEnd to idle (#3178), but for my case that's enough.

@bpinney
Copy link

bpinney commented Mar 31, 2016

Any update on when this might be added?

@bpinney
Copy link

bpinney commented Apr 4, 2016

#2267 and #2532 are open issues making the same request

@yohanboniface
Copy link
Member

The fastest way of getting this into core is a pull request ;)
We are now working on 1.0.0-rc1 release, and we have frozen the features perimeter of the 1.0, so we will basically only work on bug fixes ourselves. But any pull request will be considered.
So, to answer your question, unless someone provides a pull request, this will not be in Leaflet before 1.1 or later.

@bpinney
Copy link

bpinney commented Jun 13, 2016

Yes @yohanboniface, doing stuff is always the fastest way to get stuff done :)
I would like some direction as to which solution is best before I take on implementation as the issue doesn't look very simple. I noticed an event muting option for programmatic changes to map state via the API was suggested in #3088, this may be a solution as well.

@frankhommers
Copy link

It would be awesome if I could pass arbitrary data on the zoom function in the options, and get access to those options in the zoomstart and zoomend events.

This way I you could detect it yourself because you've passed something ;-) And also it would open a lot more possibilities.

@dmitry Did you find a better way in the mean time?

@jayachandranm
Copy link

Any updates on this issue? I still can't find a direct way to resolve this.

@IvanSanchez
Copy link
Member

There's a proposed approach at #5247. However I'm not fully convinced by it :-/

@mbrucher
Copy link

How can we make it better then?

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

Successfully merging a pull request may close this issue.