-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·89 lines (74 loc) · 2.36 KB
/
main.js
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
d3.json("assets/unam-buildings.geojson").then(function (data) {
const buildings = data;
const TILE_BASE = "https://scholarship.rrchnm.org/unam-tiles";
const buildingStyles = {
color: "green",
weight: 5,
opacity: 0.65,
};
function onFeatureClick(feature, layer) {
// does this feature have a property named popupContent?
if (feature.properties && feature.properties["Building N"]) {
layer.bindPopup(feature.properties["Building N"]);
}
}
//OSM
const osm = new L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
});
const unam1951a = new L.tileLayer(`${TILE_BASE}/UNAM_14Sept1951_tiles/{z}/{x}/{-y}.png`, {
attribution: "Photograph attribution goes here",
});
const unam1951b = new L.tileLayer(`${TILE_BASE}/UNAM_19Sept1951_tiles/{z}/{x}/{-y}.png`, {
attribution: "Photograph attribution goes here",
});
const unam1946 = new L.tileLayer(`${TILE_BASE}/UNAM_1946_tiles/{z}/{x}/{-y}.png`, {
attribution: "Photograph attribution goes here",
});
const unam1953 = new L.tileLayer(`${TILE_BASE}/UNAM_Feb1953_tiles/{z}/{x}/{-y}.png`, {
attribution: "Photograph attribution goes here",
});
const unam1965 = new L.tileLayer(`${TILE_BASE}/UNAM1965_tiles/{z}/{x}/{-y}.png`, {
attribution: "Photograph attribution goes here",
});
const buildingLayer = new L.geoJSON(buildings, {
style: buildingStyles,
onEachFeature: onFeatureClick,
});
//MAP
const map = L.map("map", {
center: [19.326, -99.187],
zoom: 13,
zoomControl: true,
minZoom: 10,
maxZoom: 16,
layers: [osm, unam1953, buildingLayer],
});
//Base layer
const Map_BaseLayer = {
"Open Street Maps": osm,
};
//Additional layers
const Map_AddLayer = {
"UNAM 1946": unam1946,
"UNAM 1951 (Sept. 14)": unam1951a,
"UNAM 1951 (Sept. 19)": unam1951b,
"UNAM 1953": unam1953,
"UNAM 1965": unam1965,
Buildings: buildingLayer,
};
//LayerControl
// Replace `Map_BaseLayer` in the call below with `null` to remove the
// radio switch for the base layer if desired.
L.control
.layers(Map_BaseLayer, Map_AddLayer, {
collapsed: false,
})
.addTo(map);
//OpacityControl
L.control
.opacity(Map_AddLayer, {
label: "Aerial photos opacity",
})
.addTo(map);
});