leaflet-semicircle
Version:
Draw semicircles on Leaflet maps
59 lines (52 loc) • 1.8 kB
HTML
<html>
<head>
<title>Leaflet rangerings example</title>
<style>
html {
height: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
vertical-align: baseline;
}
body { height: 100%; margin: 0; padding: 0;}
#map {
width: 100%; height: 100%;
}
</style>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.1.0/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.1.0/dist/leaflet.js"></script>
<script src="../Semicircle.js"></script>
</head>
<body>
<div id="map"></div>
<script>
var latlng = [50.6, -0.0];
var map = L.map('map').setView(latlng, 11);
function rangerings (latlng, options) {
options = L.extend({
count: 8,
interval: 1000,
direction: 0,
spread: 120
}, options);
var layer = L.featureGroup();
for (var i = 1; i <= options.count; i++) {
L.semiCircle(latlng, {
radius: i * options.interval,
fill: false,
color: '#000',
weight: 1
}).setDirection(options.direction, options.spread).addTo(layer);
}
return layer;
}
rangerings(latlng).addTo(map);
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
maxZoom: 18
}).addTo(map);
</script>
</body>
</html>