Leaflet: Simple GeoJSON MultiPolygons (Square Donut & Swiss Cheese)
Simple example showing necessary array structure to have holes in polygons. Useful references are the GeoJSON spec (http://geojson.org/geojson-spec.html) and the Wikipedia page on WKT (http://en.wikipedia.org/wiki/Well-known_text).
by pertrai1
HTML
<script src="http://cdn.leafletjs.com/leaflet-0.4/leaflet.js"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4/leaflet.css">
<div id="map" style="height:480px; width:360px;"></div>
JavaScript
var meta1nJson={
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-38.3613558,
-8.8044875
]
},
"properties": {
"Ordem": "193",
"Eixo": "Leste",
"Meta": "1L",
"Municipio": "Petrolândia",
"Estado": "PE",
"Nome da Comunidade": "Agrovila 4"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-38.3445892,
-8.7940031
]
},
"properties": {
"Ordem": "194",
"Eixo": "Leste",
"Meta": "1L",
"Municipio": "Petrolândia / Floresta",
"Estado": "PE",
"Nome da Comunidade": "Agrovila 5"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-37.8521847,
-8.6774657
]
},
"properties": {
"Ordem": "195",
"Eixo": "Leste",
"Meta": "1L",
"Municipio": "Inajá/Ibimirim",
"Estado": "PE",
"Nome da Comunidade": "Indígena Kambiwá - Baxa da Alexandra"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-37.9229577,
-8.645232
]
},
"properties": {
"Ordem": "196",
"Eixo": "Leste",
"Meta": "1L",
"Municipio": "Inajá",
"Estado": "PE",
"Nome da Comunidade": "Indígena Kambiwá - Barracão"
}
}
]
};
// create a map in the "map" div, set the view to a given place and zoom
var map = L.map('map', {
center: [-9, -38],
zoom: 7
});
L.tileLayer('https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png', {
id: 'examples.map-20v6611k'
}).addTo(map);
new L.GeoJSON(meta1nJson).addTo(map);