Listening to zoom and move events on maps


#1

Hi I’m trying to listen to the events of zoom and pan in Vector Map but I can not find how to do this in the events documentation, there is a way to do this easily. Thank you.


#2

Hi @ryan I think that what you are looking for is on the map documentation page, in the Listening To Custom Map Events section, is something like this:

myChart.on('mapzoom', (x)=>{
    console.log("Current map zoom: ", x.data);
});

myChart.on('mapmove', (x)=>{
    console.log("Current map center: ", x.data);
});

Let me know if this is what you are looking for. Best regards.


#3

Hi guys, I’m registering the mapzoom and mapmove event handlers but I’m getting this warning on the console: Too many events attached to the visual vectorMapDiv. This may be caused by registering the same event multiple times. Please check your code. Otherwise, everything works ok. I can just ignore the warning or I need to fix it?. Thanks


#4

Hi @pedro, this warning as It says appears when do you attach too many event listeners to the same chart. Do you need to keep a reference to each listener that you attach to a chart to be able to call to the off method to unregister them. See the section Unregister Events of the Events documentation for more information. Let me know if you have any other issue. Best regards.