Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@any-routing/maplibre-layers-event-propagator

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@any-routing/maplibre-layers-event-propagator

Maplibre GL and MapBox GL JS map engine add-on to stop event propagation between layers.

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

maplibre-layers-event-propagator

Maplibre GL and MapBox GL JS map engine add-on to stop event propagation between layers.

Installation

npm i --save @any-routing/maplibre-layers-event-propagator

Example of usage

import { Map } from 'maplibre';
import { PropagationEvent, setupLayerEventsPropagator } from '@any-routing/layers-event-propagator';

const map = new Map({});

map.on('load', () => {
  setupLayerEventsPropagator(map); // Must be handled after map loaded

  map.on('click', 'lake-label', (e: PropagationEvent<MapLayerMouseEvent>) => {
    if (e.isCancelled && e.isCancelled()) {
      return;
    }

    console.log(e, 'click on water label printed');
    e.stopPropagation ? e.stopPropagation() : null;
    e.stopImmediatePropagation ? e.stopImmediatePropagation() : null;
  });

  map.on('click', 'lake-label', (e: PropagationEvent<MapLayerMouseEvent>) => {
    if (e.isCancelled && e.isCancelled()) {
      return;
    }

    console.log(e, 'click on water label no printed');
    e.stopPropagation ? e.stopPropagation() : null;
  });

  map.on('click', 'water', (e: PropagationEvent<MapLayerMouseEvent>) => {
    if (e.isCancelled && e.isCancelled()) {
      return;
    }

    console.log(e, 'click on water');
    e.stopPropagation ? e.stopPropagation() : null;
  });

  map.on('click', (e: PropagationEvent<MapLayerMouseEvent>) => {
    //For non layer handlers
    if (e.originalEvent.isCancelled && e.originalEvent.isCancelled()) {
      return;
    }

    console.log(e, 'click anywhere else');
  });
});

FAQs

Package last updated on 01 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc