-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
74 lines (63 loc) · 3.43 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html>
<head>
<title>leaflet-map-simple-instructor-sample</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<!-- Load Leaflet code library - see updates at http://leafletjs.com/download.html -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<!-- Load Omnivore plugin to convert CSV to GeoJSON format -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/leaflet-omnivore/0.3.4/leaflet-omnivore.min.js'></script>
<!-- Position the map and title with Cascading Style Sheet (.css) -->
<style>
body { margin:0; padding:0; }
#map { position: absolute; top:0; bottom:0; right:0; left:0; }
#map-title { position: relative; margin-top: 10px; margin-left: 50px; float: left; background: white; border: 2px solid rgba(0,0,0,0.2); padding: 6px 8px; font-family: Helvetica; font-weight: bold; font-size: 24px; z-index: 800; }
</style>
</head>
<body>
<!-- Display the map and title with HTML division tags -->
<div id="map-title">Higher Ed in Hartford Region</div>
<div id="map"></div>
<!-- Create the map content with JavaScript (.js) -->
<script>
/* Set up the map with initial center and zoom level */
var map = L.map('map', {
center: [41.77, -72.69], // EDIT latitude, longitude to re-center map
zoom: 12, // EDIT from 1 to 18 -- decrease to zoom out, increase to zoom in
scrollWheelZoom: false,
tap: false
});
/* Control panel to display map layers */
var controlLayers = L.control.layers( null, null, {
position: "topright",
collapsed: false
}).addTo(map);
/* Carto light-gray basemap tiles with labels */
var light = L.tileLayer('https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png', {
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, © <a href="https://carto.com/attribution">CARTO</a>'
}); // EDIT - insert or remove ".addTo(map)" before last semicolon to display by default
controlLayers.addBaseLayer(light, 'Carto Light basemap');
/* Stamen colored terrain basemap tiles with labels */
var terrain = L.tileLayer('https://stamen-tiles.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png', {
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.'
}).addTo(map); // EDIT - insert or remove ".addTo(map)" before last semicolon to display by default
controlLayers.addBaseLayer(terrain, 'Stamen Terrain basemap');
/* Display a blue point marker with pop-up text */
// L.marker([41.77, -72.69]).addTo(map) // EDIT latitude, longitude to re-position marker
// .bindPopup("Insert pop-up text here"); // EDIT pop-up text message
/* Upload Latitude/Longitude markers from data.csv file, show Title in pop-up, and override initial center and zoom to fit all in map */
var customLayer = L.geoJson(null, {
onEachFeature: function(feature, layer) {
layer.bindPopup(feature.properties.Title);
}
});
var runLayer = omnivore.csv('data.csv', null, customLayer)
.on('ready', function() {
map.fitBounds(runLayer.getBounds());
}).addTo(map);
controlLayers.addOverlay(customLayer, 'Markers from data.csv');
</script>
</body>
</html>