Skip to content

Commit

Permalink
feat: Emit more useful map events for iframe integration (closes #388)
Browse files Browse the repository at this point in the history
  • Loading branch information
claustres committed Oct 2, 2024
1 parent bed94e9 commit 0d71a29
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/components/MapActivity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,14 @@ export default {
const handler = (options, event) => {
// event may be disabled by config
const opts = this.activityOptions
let okForward = leafletEvent === 'click' || leafletEvent === 'dblclick'
if (opts.allowForwardEvents) okForward = okForward || opts.allowForwardEvents.indexOf(leafletEvent) !== -1
if (opts.disallowForwardEvents) okForward = okForward && opts.disallowForwardEvents.indexOf(leafletEvent) === -1
const defaultLeafletEvents = ['click', 'dblclick', 'contextmenu']
let okForward = (defaultLeafletEvents.indexOf(leafletEvent) !== -1 )
if (opts.allowForwardEvents) okForward = okForward || (opts.allowForwardEvents.indexOf(leafletEvent) !== -1)
if (opts.disallowForwardEvents) okForward = okForward && (opts.disallowForwardEvents.indexOf(leafletEvent) === -1)
if (!okForward) return
const latlng = _.get(event, 'latlng')
const feature = _.get(event, 'target.feature') || _.get(event, 'feature')
// feature required for those events
if (leafletEvent === 'mouseover' && !feature) return
// Retrieve original layer options not processed ones
// as they can include internal objects not to be serialized
const layer = (options ? this.getLayerByName(options.name) : undefined)
Expand Down Expand Up @@ -299,7 +298,7 @@ export default {
},
mounted () {
// Setup event connections
const allLeafletEvents = ['click', 'dblclick', 'mouseover']
const allLeafletEvents = ['click', 'dblclick', 'contextmenu', 'mouseover', 'mouseout', 'mousemove']
this.forwardLeafletEvents(allLeafletEvents)
const allLayerEvents = ['layer-added', 'layer-shown', 'layer-hidden', 'layer-removed', 'layer-updated']
this.forwardLayerEvents(allLayerEvents)
Expand Down

0 comments on commit 0d71a29

Please sign in to comment.