leaflet-semicircle
Version:
Draw semicircles on Leaflet maps
61 lines (54 loc) • 1.69 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 = [50.6, -0.0];
var map = L.map('map').setView(latlng, 11);
var radius = 500;
L.circle(latlng, {
radius: radius,
fill: true,
fillColor:'#a1ba03',
fillOpacity: 0.5,
color: '#a1ba03',
opacity: 0.5,
startAngle: 0,
stopAngle: 360
}).addTo(map);
L.circle(latlng, {
radius: radius,
fill: true,
fillColor:'#fff',
fillOpacity: 0.5,
color: '#fff',
opacity: 0.5,
startAngle: 20,
stopAngle: 340
}).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>