Skip to content

lycheelin/react-leaflet-canvas-markers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React leaflet canvas markers

React wrapper of Leaflet.Canvas-Markers for react-leaflet

Description

Leaflet plugin for displaying markers on canvas instead of DOM. Working with Leaflet 1.0.0 and above.

react-leaflet v2.x support

Note: Before getting started, please see these useful guides:

Getting started

Just download CanvasMarkersLayer.js and leaflet.canvas-markers.js from the src folder and attach it to your component.

import CanvasMarkersLayer from '../src/CanvasMarkersLayer';

The leaflet.canvas-markers.js in the src folder comes from Leaflet.Canvas-Markers, and it has be modified.

(You can import the source)

yarn add leaflet-canvas-marker # yarn

in CanvasMarkersLayer.js

require('../node_modules/leaflet-canvas-marker/src/leaflet.canvas-markers');

Write some simple react-leaflet Map:

<Map center={[22.5774626732038, 114.04924392700197]} zoom={11}>
  <TileLayer
    url="http://{s}.tile.osm.org/{z}/{x}/{y}.png"
    attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
  />
  <CanvasMarkersLayer>
    <Marker position={[22.5774626732038, 114.04924392700197]} icon={defaultIcon}>
        <Popup>
          <div>hello !</div>
        </Popup>
    </Marker>
  </CanvasMarkersLayer>
</Map>

How to run demo app

1. Clone our repo:

git clone https://github.com/lycheelin/react-leaflet-canvas-markers.git

2. Install all dependencies:

yarn install --no-lockfile # yarn
npm install # npm

3. Start the server:

yarn start  # yarn
npm start   # npm

4. After starting the server, webpack should automatically open the following address:

http://localhost:3000/

License

MIT License

About

React wrapper of Leaflet.Canvas-Markers for react-laeflet

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published