leaflet-plugins
Version:
Miscellaneous plugins for Leaflet library for services that need to display route information and need satellite imagery from different providers
37 lines (33 loc) • 1.03 kB
HTML
<html>
<head>
<title>Leaflet</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.5.1/dist/leaflet.js"></script>
<script src="../layer/Icon.Canvas.js"></script>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script type='text/javascript'>
var center = [67.6755, 33.936];
var map = L.map('map', {center: center, zoom: 10});
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
var circle = new L.Icon.Canvas({iconSize: L.point(30, 30)});
circle.draw = function (ctx, w, h) {
ctx.translate(w/2, h/2);
ctx.beginPath();
ctx.fillStyle = '#F00';
ctx.arc(0, 0, w/2-1, 0, Math.PI*2, true);
ctx.fill();
ctx.lineWidth = 2;
ctx.strokeStyle = '#FFF';
ctx.moveTo(-w/5, -h/5);
ctx.lineTo(w/5, h/5);
ctx.moveTo(-w/5, h/5);
ctx.lineTo(w/5, -h/5);
ctx.stroke();
ctx.closePath();
};
L.marker(center, {icon: circle, draggable: true, opacity: 0.7}).addTo(map);
</script>
</body>
</html>