1.0.7 • Published 3 years ago

leaflet-canvas-markers v1.0.7

Weekly downloads
59
License
ISC
Repository
github
Last release
3 years ago

一 A JavaScript Integrated Leaflet Map API

Leaflet-canvas-markers

Adding all images to one canvas, together with the base L.CircleMarker! And you can create a direction arrow just by pointing to the previous waypoint.

Demo

Live Demo >>

Base Usage

const map = L.map('map', {preferCanvas: true}).setView([51.505, -0.09], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);

L.canvasMarker(L.latLng(51.495, -0.06), {
    radius: 20,
    img: {
        url: 'icon.png',    //image link
        size: [40, 40],     //image size ( default [40, 40] )
        rotate: 10,         //image base rotate ( default 0 )
        offset: { x: 0, y: 0 }, //image offset ( default { x: 0, y: 0 } )
    },
}).addTo(map);

Direction Arrow

You can specify the previous point (prevLatlng: latlng). The picture will automatically show the direction of movement.

const map = L.map('map', {preferCanvas: true}).setView([51.505, -0.09], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);

L.canvasMarker(L.latLng(51.495, -0.06), {
    radius: 20,
    prevLatlng: L.latLng(51.503, -0.09),    //previous point
    img: {
        url: 'arrow.png',
        size: [40, 40],
        rotate: 0,
    },
}).addTo(map);

Options

OptionTypeDescription
imgObjectImage properties
prevLatlngLatLngThe coordinates of the previous point. If indicated - The image automatically shows the direction

Options img

OptionTypeDefaultDescription
urlStringImage link
sizeArray[40, 40]Image size in map
rotateNumber0Image rotate in map
offsetObject{ x: 0, y: 0 }Image offset in Canvas
1.0.7

3 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago