diff --git a/src/js/core/setupElementEvents.js b/src/js/core/setupElementEvents.js index 5352a48..3e97b75 100644 --- a/src/js/core/setupElementEvents.js +++ b/src/js/core/setupElementEvents.js @@ -1,5 +1,6 @@ import { getElement } from '../util/index' import EventHandler from '../eventHandler' +import Events from '../defaults/events' function parseEvent(map, selector, isTooltip) { var element = getElement(selector), @@ -99,4 +100,14 @@ export default function setupElementEvents() { ]) } }) + + // When region/marker is clicked + EventHandler.delegate(container, 'click', '.jvm-element', function (event) { + const { type, code } = parseEvent(map, this) + + map._emit( + type === 'region' ? Events.onRegionClick : Events.onMarkerClick, + [event, code] + ) + }) } \ No newline at end of file diff --git a/src/js/defaults/events.js b/src/js/defaults/events.js index 1bf8505..69cb3f9 100644 --- a/src/js/defaults/events.js +++ b/src/js/defaults/events.js @@ -1,5 +1,7 @@ export default { onViewportChange: 'viewport:changed', + onRegionClick: 'region:clicked', + onMarkerClick: 'marker:clicked', onRegionSelected: 'region:selected', onMarkerSelected: 'marker:selected', onRegionTooltipShow: 'region.tooltip:show',