Skip to content

Instantly share code, notes, and snippets.

@mollietaylor
Last active December 26, 2015 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mollietaylor/7110969 to your computer and use it in GitHub Desktop.
Save mollietaylor/7110969 to your computer and use it in GitHub Desktop.
Make All Polygons the Same Shade in Leaflet
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<title>Quick Start</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]-->
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
<style type="text/css">
#map {
height: 500px;
}
</style>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
var map = L.map('map').setView([51.505, -0.09], 13);
var defaultStyle = {
color: 'green',
fillOpacity: 0.2
};
L.tileLayer('http://{s}.tile.cloudmade.com/API-key/997/256/{z}/{x}/{y}.png', {
attribution: 'Map data &copy; <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 polygon = L.polygon([
[51.509, -0.08],
[51.503, -0.06],
[51.51, -0.047]
]).setStyle(defaultStyle).addTo(map);
var circle = L.circle([51.508, -0.11], 500).setStyle(defaultStyle).addTo(map);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment