ammap3 icon indicating copy to clipboard operation
ammap3 copied to clipboard

OnBackgroundClicked

Open joneswe opened this issue 7 years ago • 2 comments

Is there a good solution to figure out that the map-background has clicked?

joneswe avatar Oct 11 '17 09:10 joneswe

solved the problem:

map.background.click(() => {
           // do something
        });

haven't found it, because i looked for events or handlers in the doku.

EDIT: It doesn't work in Chrome

joneswe avatar Oct 12 '17 07:10 joneswe

I'd probably still go with build in events. If you need to specifically catch click on non-object, you might combine click and clickMapObject events.

Something like this:

  "listeners": [{
    "event": "click",
    "method": function(ev) {
      ev.chart.clickTimeout = setTimeout(function () {
        console.log("click");
      }, 10);
    }
  }, {
    "event": "clickMapObject",
    "method": function(ev) {
      clearTimeout(ev.chart.clickTimeout);
      console.log("clickMapObject")
    }
  }]

Here's a working demo: https://codepen.io/team/amcharts/pen/60ea204a3b4846c0288d460103601c10?editors=0010

Hope this helps.

martynasma avatar Oct 12 '17 16:10 martynasma