-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
157 lines (134 loc) · 3.57 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html>
<head>
<title>Firestone V3 Map - Credit: cityuser + jackfrojpg</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI="
crossorigin=""/>
<!-- Make sure you put this AFTER Leaflet's CSS -->
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM="
crossorigin=""></script>
<script src="Leaflet.LabelTextCollision.js"></script>
<script src="Canvas-TextPath.js"></script>
<script src="Leaflet.streetlabels.js"></script>
<script src="roads.js"></script>
</head>
<body>
<style>
html, body {
margin: 0;
height: 100%;
}
.leaflet-container {
background: #436270;
outline-offset: 1px;
}
#map { height: 100%; }
</style>
<div id="map"></div>
<script>
var streetLabelsRenderer = new L.StreetLabels({
//color : "#ff0000",
collisionFlg : true,
propertyName : 'name',
showLabelIf: function(layer) {
return true; //layer.properties.type == "primary";
},
fontStyle: {
//color : "#ff0000",
dynamicFontSize: false,
fontSize: 15, // was 15
fontSizeUnit: "px",
lineWidth: 4.0, // was 4.0
fillStyle: "black",
strokeStyle: "white",
},
//lineStyle: {
//color: "#ff0000",
//}
})
// Load the dataset
var dataset = L.geoJSON(roads, {
onEachFeature: onEachFeature
//color: color: "#ff0000"
})
function highlightFeature(e) {
var layer = e.target;
layer.setStyle({
stroke: true,
weight: 8,
dashArray: '',
opacity: 0.5,
color: '#ff3300'
});
if (!L.Browser.ie && !L.Browser.opera) {
layer.bringToFront();
}
}
function resetHighlight(e) {
dataset.resetStyle(e.target);
var layer = e.target;
layer.setStyle({
weight: 4,
color: '#3388ff',
dashArray: '',
fillOpacity: 1
});
}
function onEachFeature(feature, layer) {
// do something with the features here (bind popups, etc.)
/*
layer.setStyle({
weight: 10,
color: 'green',
fillOpacity: 0,
})
*/
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight,
});
}
// Add map, set default view
var map = L.map('map', {
crs: L.CRS.Simple,
minZoom: -1,
center: [0,0],
renderer: streetLabelsRenderer,
layers: [dataset],
}).setView([-300,500], 0);
// Add tile layer
var t = L.tileLayer('tiles/{z}/{x}/{y}.png', {
noWrap: true,
tileSize: L.point(1021, 644),
minNativeZoom: 0,
maxNativeZoom: 4,
minZoom: -1,
maxZoom: 5,
bounds: [[0,0],[-643,1020]]
}).addTo(map);
L.control.layers({ "Satellite": t /*only 1 can be picked from here, separate with ;*/}, { "Roads": dataset /*can toggle any number, separate with ;*/}).addTo(map)
// for testing
/*
var popup = L.popup();
let listString = ""
let debounce = false
async function onMapClick(e) {
if (debounce === false) {
debounce = true
let initialCoords = e.latlng.toString().split("(")[1].split(")")[0]
const splitted = initialCoords.split(", ")
initialCoords = "[" + splitted[1] + ", " + splitted[0] + "], "
listString = listString + initialCoords
console.log(listString)
await new Promise(resolve => setTimeout(resolve, 100))
debounce = false
}
}
map.on('click', onMapClick);
*/
//
</script>
</body>
</html>