forked from uafrazier's block: Leaflet Map with a Polygon
Created
April 24, 2016 14:51
-
-
Save andreaangeli/10d5838ba94837696e6a11e03ec0535b to your computer and use it in GitHub Desktop.
Leaflet Map with a Polygon
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> | |
<title>Leaflet Web Map</title> | |
<!-- reference to Leaflet CSS --> | |
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" /> | |
<!-- reference to Leaflet JavaScript --> | |
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script> | |
<!-- set width and height styles for map --> | |
<style> | |
#map { | |
width: 960px; | |
height:500px; | |
} | |
</style> | |
</head> | |
<body> | |
<!-- place holder for map --> | |
<div id="map"></div> | |
<script> | |
// create map object, tell it to live in 'map' div and give initial latitude, longitude, zoom values | |
// pass option to turn scroll wheel zoom off | |
var map = L.map('map',{scrollWheelZoom:false}).setView([43.64701, -79.39425], 15); | |
// add base map tiles from OpenStreetMap and attribution info to 'map' div | |
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { | |
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' | |
}).addTo(map); | |
// define array of points for polygon | |
var area = [ [43.64381, -79.40266],[43.64931, -79.39098],[43.64667, -79.3845] ]; | |
// add polygon from area array points to map with some basic styling | |
L.polygon(area,{color:'purple',opacity:.6}).addTo(map); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment