Skip to content

Instantly share code, notes, and snippets.

@leenoah1
Last active October 24, 2017 17:19
Show Gist options
  • Save leenoah1/c6cb58257f6069bfb9d1d305df36e621 to your computer and use it in GitHub Desktop.
Save leenoah1/c6cb58257f6069bfb9d1d305df36e621 to your computer and use it in GitHub Desktop.
leaflet map gist
license: mit
<!DOCTYPE html>
<html>
<head>
<title>Anacostia River Map</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
</head>
<body>
<div id="mapid" style="width: 960px; height: 500px;"></div>
<script src="https://leenoah1.github.io/class_project/census.js" type="text/javascript"></script>
<script>
// mapview creation
var mymap = L.map('mapid').setView([38.88355, -76.96301], 13);
// Add a tile layer to the mapview
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
maxZoom: 18,
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://mapbox.com">Mapbox</a>',
id: 'mapbox.streets'
}).addTo(mymap);
L.marker([38.87032, -76.99751]).addTo(mymap)
.bindPopup("<b>I am a popup on the Anacostia River.").openPopup();
;
var popup = L.popup();
function onMapClick(e) {
popup
.setLatLng(e.latlng)
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(mymap);
}
mymap.on('click', onMapClick);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment