Last active
December 23, 2015 02:09
-
-
Save gavinr/6565204 to your computer and use it in GitHub Desktop.
Leaflet Circle GeoJSON Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Test</title> | |
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" /> | |
<!--[if lte IE 8]> | |
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" /> | |
<![endif]--> | |
<style> | |
#map { height: 100%; } | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script> | |
<script> | |
var map = L.map('map').setView([51.505, -0.09], 13); | |
L.tileLayer('http://{s}.tile.cloudmade.com/3c674276894b4bd1bcb0e98ecbdf875b/997/256/{z}/{x}/{y}.png', { | |
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://cloudmade.com">CloudMade</a>', | |
maxZoom: 18 | |
}).addTo(map); | |
var drawnItems = new L.FeatureGroup(); | |
map.addLayer(drawnItems); | |
map.on('layeradd', function (e) { | |
drawnItems.addLayer(e.layer); | |
alert(JSON.stringify(e.layer.toGeoJSON())); | |
}); | |
var circle = L.circle([51.508, -0.11], 500, { | |
color: 'red', | |
fillColor: '#f03', | |
fillOpacity: 0.5 | |
}).addTo(map); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment