forked from ryerson-ggl/tutorial-express-leaflet
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebmap3.js
More file actions
49 lines (38 loc) · 1.69 KB
/
webmap3.js
File metadata and controls
49 lines (38 loc) · 1.69 KB
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
// main leaflet JS file -> user browersify to generate a package that can be use
// as frontend code!!!
// Import the leaflet package
var L = require('leaflet'); //npm install --save leaflet
var L1 = require('leaflet.markercluster'); //npm install --save leaflet
// Creates a leaflet map binded to an html <div> with id "map"
// setView will set the initial map view to the location at coordinates
// 13 represents the initial zoom level with higher values being more zoomed in
var map = L.map('map', {
center: [38.829772, -77.305550],
zoom: 11
});
// Adds the basemap tiles to your web map
// Additional providers are available at: https://leaflet-extras.github.io/leaflet-providers/preview/
L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner/{z}/{x}/{y}{r}.{ext}', {
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
minZoom: 0,
maxZoom: 40,
ext: 'png'
}).addTo(map);
// Adds a popup marker to the webmap for GGL address
L.circleMarker([38.829772, -77.305550]).addTo(map)
.bindPopup(
'<b>Geography and Geoinformation Science Dept.</b><br>' +
'Exploratory Hall<br>' +
'George Mason University<br>' +
'Fairfax, VA'
)
.openPopup();
// Adding the GEOJSON DATA
// This takes the JsonData that was sent with the GET request .
var datastr_clean = datastr.replace(/"/g, '\"');
var geojsonobj = JSON.parse(datastr_clean);
//var spatial_data = jsonData;
console.log(datastr_clean);
var group = new L.markerClusterGroup().addTo(map);
L.geoJSON(geojsonobj).addTo(group);
//-77.9848, 38.4657