-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_leaf_prune.html
144 lines (118 loc) · 3.88 KB
/
index_leaf_prune.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
<html>
<head>
<meta charset="utf-8" />
<title>PruneCluster - Realworld 50k</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-beta.2.rc.2/leaflet.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-beta.2.rc.2/leaflet.js"></script>
<script src="js/PruneCluster.js"></script>
<link rel="stylesheet" href="style/examples.css"/>
<script src="js/pool.js"></script>
<script src="js/app.js"></script>
<link rel="stylesheet" href="style/custom.css"/>
</head>
<body>
<div id='map'></div>
<script>
function initFeatures(size) {
for(var i=0; i < size; i++) {
var newFeature = {
"id": i,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [generateLon(), generateLat()]
}
};
addFeature(newFeature);
}
myCluster.ProcessView();
}
function goHome() {
stopGeneratingFeatures();
myCluster.RemoveMarkers();
markers.clear();
map.setView([center_lat, center_lon], initialZoom);
}
var airportSvgIcon = L.icon({
iconUrl: 'assets/airport-24.svg',
iconSize: [24, 24],
iconAnchor: [24, 24],
popupAnchor: [-12, -28]
});
var customIcon = new L.Icon.Default({
shadowSize: [0,0]
});
var airportIcon = L.icon({
iconUrl: 'assets/airport-24.png',
iconRetinaUrl: 'assets/airport-24.png',
iconSize: [24, 24],
iconAnchor: [24, 24],
popupAnchor: [-12, -28]
});
function addOrMoveFeature(newFeature) {
var foundMarker = markers.getItem(newFeature.id);
if(foundMarker !== undefined) {
moveFeature(foundMarker, newFeature);
} else {
addFeature(newFeature);
}
}
function addFeature(newFeature) {
addFeatureLight(newFeature);
}
function createIcon(data, category) {
return customIcon;
}
function moveFeature(foundMarker, newFeature) {
foundMarker.Move(newFeature.geometry.coordinates[1], newFeature.geometry.coordinates[0]);
myCluster.ProcessView();
}
function addFeatureLight(newFeature) {
var newMarker = new PruneCluster.Marker(newFeature.geometry.coordinates[1], newFeature.geometry.coordinates[0]);
//newMarker.category = newFeature.category;
//newMarker.weight = newFeature.weight;
//newMarker.filtered = true;
//newMarker.data.forceIconRedraw = false;
newMarker.data.popup = "Feature: " + newFeature.id + "<br/><img src='assets/indio.gif' width='250px'/>";
newMarker.data.icon = createIcon;
markers.setItem(newFeature.id, newMarker);
myCluster.RegisterMarker(newMarker);
}
function refreshMap() {
myCluster.ProcessView();
}
function filter() {
for (var key in markers.getItems()) {
markers.getItem(key).filtered = (key <= Number(filterId.value));
}
myCluster.ProcessView();
}
var map = L.map('map', {
zoomControl: false,
attributionControl: false
}).setView([center_lat, center_lon], initialZoom);
var baseMapLayer = L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.jpg70?access_token={accessToken}', {
maxZoom: maxZoom,
minZoom: minZoom,
id: 'mapbox.streets',
accessToken: MAPBOX_TOKEN
}).addTo(map);
/*var vectorTilesLayer = new L.TileLayer.MVTSource({
url: 'http://85.87.53.115/geoserver/gwc/service/tms/1.0.0/etx:oip_link@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf',
tms: true,
style: simpleStyle,
debug: false
}).addTo(map);*/
//var myLayer = L.geoJson(features).addTo(map);
var myCluster = new PruneClusterForLeaflet();
map.addLayer(myCluster);
</script>
<div id="foregroundContent">
<button onclick="goHome()">Fly home</button>
<button onclick="generateFeatures()">Generate features</button>
<button onclick="stopGeneratingFeatures()">Stop Generating features</button>
<input id="filterId" type="number" value="200"></input>
<button onclick="filter()">Filter</button>
</div>
</body>
</html>