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

leaflet-markers-canvas

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leaflet-markers-canvas

A Leaflet plugin to render many markers in a canvas instead of the DOM

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
528
decreased by-20.96%
Maintainers
1
Weekly downloads
 
Created
Source

leaflet-markers-canvas

A Leaflet plugin to render many markers in a canvas instead of the DOM.

This is a complete rewrite of Leaflet.Canvas-Markers by Eugene Voynov. Thank you for the inspiration.

Demo

Here is a demo of 10000 markers, displayed in one canvas.

Usage

Dependencies

Leaflet and RBush must be available globally or installed as peer-dependencies.

Install

  • Install from npm (npm i leaflet-markers-canvas)
  • or download leaflet-markers-canvas.js from the dist folder.

Exemple

var map = L.map("map").setView([59.9578, 30.2987], 10);
var tiles = L.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png", {
  attribution:
    '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
  preferCanvas: true,
}).addTo(map);

var markersCanvas = new L.markersCanvas();
markersCanvas.addTo(map);

var icon = L.icon({
  iconUrl: "marker.png",
  iconSize: [20, 32],
  iconAnchor: [10, 0],
});

var methods = {
  mouseover(e) {
    this.openPopup();
  },
  mouseout(e) {
    this.closePopup();
  },
};

var markers = [];

for (var i = 0; i < 10000; i++) {
  var marker = L.marker(
    [58.5578 + Math.random() * 1.8, 29.0087 + Math.random() * 3.6],
    { icon: icon }
  )
    .bindPopup("I Am " + i)
    .on(methods);

  markers.push(marker);
}

markersCanvas.addMarkers(markers);

Methods

addTo(map)

getBounds()

redraw()

clear()

addMarker(marker)

addMarkers(markers)

removeMarker(marker)

To-do

  • Complete documentation

Keywords

FAQs

Package last updated on 04 Jan 2021

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