leaflet-semicircle
Version:
Draw semicircles on Leaflet maps
55 lines (47 loc) • 1.57 kB
HTML
<html>
<head>
<title>Leaflet Semicircle 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 = [51.508, -0.09];
var map = L.map('map').setView(latlng, 8);
var dir = 270;
var circle = L.semiCircle(latlng, {
radius: 50000,
weight: 10,
color: '#ff0',
opacity: 1,
fillOpacity: 0.9
}).setDirection(dir, 270).addTo(map);
var open, counter = 1;
setInterval(function () {
counter += 0.5;
open = 358 - (1 + Math.sin(counter)) * 45;
circle.setDirection(dir, open);
}, 80);
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>