0

I just want to make onclick event in zoom in and zoom out. How can I do it? I just confused to make it because zoom in and zoom out is something that generated by library.

Should I make new function? How I make it possible?

closed as off-topic by MrXsquared, neogeomat, Jochen Schwarze, LaughU, Erik Sep 27 at 7:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – MrXsquared, Jochen Schwarze, LaughU
If this question can be reworded to fit the rules in the help center, please edit the question.

1

Assuming your map variable is called map, this zooms in when you click the map:

map.on('click', function() {

   map.zoomIn();

});

If you're asking to fire an event when zooming happens, then use:

map.on('zoom', function() {

   alert('Zoom, zoom, zoom, zoom, I want you in my room');

});

You can also use the zoomend or zoomend events.

  • Amazing alert!!haha – Fran Raga Sep 26 at 19:48
  • thank you!! it works – Ray Coder Oct 1 at 16:58
0

Use map events. zoomstart,zoom,zoomend can be used. e.g.

map.on({zoom : yourfunction})
  • thank you it works!! – Ray Coder Oct 1 at 16:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.