Skip to content

Commit

Permalink
feat(events): onRegion/MarkerClick support (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
themustafaomar committed Jul 6, 2022
1 parent 184c1fc commit 1de5d78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/js/core/setupElementEvents.js
Original file line number Diff line number Diff line change
@@ -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),
Expand Down Expand Up @@ -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]
)
})
}
2 changes: 2 additions & 0 deletions src/js/defaults/events.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit 1de5d78

Please sign in to comment.