Socket
Socket
Sign inDemoInstall

@raruto/leaflet-gesture-handling

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@raruto/leaflet-gesture-handling

A Leaflet plugin that allows to prevent default map scroll/touch behaviours


Version published
Weekly downloads
1.8K
increased by5.23%
Maintainers
1
Weekly downloads
 
Created
Source

leaflet-gesture-handling.js

A Leaflet plugin that allows to prevent default map scroll/touch behaviours.

For a working example see demo

Ctrl + scroll to zoom the map


Initially based on the work of elmarquis


How to use

  1. include CSS & JavaScript
    <head>
    ...
    <style> html, body, #map { height: 100%; width: 100%; padding: 0; margin: 0; } </style>
    <!-- Leaflet (JS/CSS) -->
    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css" />
    <script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"></script>
    <!-- leaflet-gesture-handling -->
    <link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-gesture-handling@latest/dist/leaflet-gesture-handling.min.css" type="text/css">
    <script src="https://unpkg.com/@raruto/leaflet-gesture-handling@latest/dist/leaflet-gesture-handling.min.js"></script>
    ...
    </head>
    
  2. choose the div container used for the slippy map
    <body>
    ...
    <div id="map"></div>
    ...
    </body>
    
  3. create your first simple “leaflet-gesture-handling” slippy map
    <script>
      ...
      var map = new L.Map('map', {
        center: [41.4583, 12.7059],
        zoom: 5,
        gestureHandling: true,
        gestureHandlingOptions: { // OPTIONAL
          // text: {
          //   touch: "Hey bro, use two fingers to move the map",
          //   scroll: "Hey bro, use ctrl + scroll to zoom the map",
          //   scrollMac: "Hey bro, use \u2318 + scroll to zoom the map"
          // },
          // locale: 'en', // set language of the warning message.
          // duration: 5000 // set time in ms before the message should disappear.
        }
      });
      ...
    </script>
    

Related: Leaflet-UI presets


Compatibile with: leaflet@1.3.4


Contributors: Elmarquis, Raruto

Keywords

FAQs

Package last updated on 12 Apr 2022

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