Javascript examples for Leaflet:Polygon
Leaflet.js - add multiple holes/cutouts inside of a Single Polygon
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css"> <script type="text/javascript" src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet-src.js"></script> <style id="compiled-css" type="text/css"> #map {/* ww w .j a va 2s . co m*/ height: 500px; } </style> <script type="text/javascript"> window.onload=function(){ var map = L.map("map").setView([48.86, 2.35], 12); L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' }).addTo(map); var coords = [ [ // Exterior Ring [48.84, 2.3], [48.9, 2.3], [48.9, 2.4], [48.84, 2.4], [48.84, 2.3] ], // Then holes (interior rings) [ // First hole [48.85, 2.31], [48.89, 2.31], [48.89, 2.33], [48.85, 2.33], [48.85, 2.31] ], [ // Second hole [48.85, 2.34], [48.89, 2.34], [48.89, 2.35], [48.85, 2.35], [48.85, 2.34] ], [ // Third hole [48.85, 2.36], [48.89, 2.36], [48.89, 2.39], [48.85, 2.39], [48.85, 2.36] ] ]; L.polygon(coords).addTo(map); } </script> </head> <body> <div id="map"></div> </body> </html>