Last active
January 21, 2018 19:10
-
-
Save NPashaP/3b71e971c5c863b04c7d44f40d94e3b3 to your computer and use it in GitHub Desktop.
Leaflet - geoJSON - Polygons
This file contains 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
license: gpl-3.0 |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"/> | |
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script> | |
<style> | |
*{ | |
margin:0; | |
} | |
#map { | |
width: 100vw; | |
height: 100vh; | |
} | |
</style> | |
</head> | |
<body> | |
<div id='map'></div> | |
<script src="http://vizjs.org/viz.v1.3.0.min.js"></script> | |
<script> | |
var map = L.map('map',{ center: [37.1, -95.7],zoom: 5}); | |
L.tileLayer(viz.leaflet.tiles.OpenStreetMap.WorldStreet, { | |
attribution: viz.leaflet.tiles.OpenStreetMap.attribution | |
}).addTo(map); | |
L.geoJSON(getGeoJSON()).addTo(map); | |
function getGeoJSON(){ | |
return { | |
"type": "Feature", | |
"properties": { | |
"attribute": "some geometry" | |
}, | |
"geometry": { | |
"type": "MultiPolygon", | |
"coordinates": [ | |
[[[-107, 40],[-93, 43],[-86, 39],[-100, 33]] | |
,[[-98, 38],[-93, 40],[-97, 41]] | |
] | |
,[[[-90, 33],[-80, 33],[-80, 30],[-90, 30]]] | |
] | |
} | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment