|
|
@ -74,42 +74,18 @@
|
|
|
|
<div id="popup" class="popup" title="Welcome to OpenLayers"></div>
|
|
|
|
<div id="popup" class="popup" title="Welcome to OpenLayers"></div>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
function loadMap() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Marker layer
|
|
|
|
|
|
|
|
markerLayer = new ol.layer.Vector({
|
|
|
|
|
|
|
|
source: new ol.source.Vector({
|
|
|
|
|
|
|
|
features: [],
|
|
|
|
|
|
|
|
projection: 'EPSG:3857'
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create the map
|
|
|
|
|
|
|
|
var map = new ol.Map({
|
|
|
|
|
|
|
|
target: 'map',
|
|
|
|
|
|
|
|
layers: [
|
|
|
|
|
|
|
|
new ol.layer.Tile({
|
|
|
|
|
|
|
|
source: new ol.source.OSM(),
|
|
|
|
|
|
|
|
preload: 4
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
markerLayer
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
view: new ol.View({
|
|
|
|
|
|
|
|
center: ol.proj.fromLonLat([0, 25]),
|
|
|
|
|
|
|
|
zoom: 1
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function delay(ms) {
|
|
|
|
|
|
|
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fetch('?fetch=1')
|
|
|
|
async function fetchWithDelay(total, delayMs) {
|
|
|
|
.then((response) => response.json())
|
|
|
|
for(let i=0; i < total + 1; i++) {
|
|
|
|
.then((data) => {
|
|
|
|
console.log(`Fetching page ${i}`)
|
|
|
|
let total = data.total;
|
|
|
|
try {
|
|
|
|
for(i=0;i<total+1;i++) {
|
|
|
|
await fetch(`?fetch=1&offset=${i}`)
|
|
|
|
fetch(`?fetch=1&offset=${i}`)
|
|
|
|
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then((d) => {
|
|
|
|
.then((d) => {
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
|
|
for (var url in d.peers) {
|
|
|
|
for (var url in d.peers) {
|
|
|
|
let peer = d.peers[url];
|
|
|
|
let peer = d.peers[url];
|
|
|
|
var feature = new ol.Feature(
|
|
|
|
var feature = new ol.Feature(
|
|
|
@ -133,10 +109,45 @@
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
markerLayer.getSource().addFeature(feature);
|
|
|
|
markerLayer.getSource().addFeature(feature);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 400)
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
console.error(`Error on request ${i}`);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
await delay(delayMs);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function loadMap() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Marker layer
|
|
|
|
|
|
|
|
markerLayer = new ol.layer.Vector({
|
|
|
|
|
|
|
|
source: new ol.source.Vector({
|
|
|
|
|
|
|
|
features: [],
|
|
|
|
|
|
|
|
projection: 'EPSG:3857'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create the map
|
|
|
|
|
|
|
|
var map = new ol.Map({
|
|
|
|
|
|
|
|
target: 'map',
|
|
|
|
|
|
|
|
layers: [
|
|
|
|
|
|
|
|
new ol.layer.Tile({
|
|
|
|
|
|
|
|
source: new ol.source.OSM(),
|
|
|
|
|
|
|
|
preload: 4
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
markerLayer
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
view: new ol.View({
|
|
|
|
|
|
|
|
center: ol.proj.fromLonLat([0, 25]),
|
|
|
|
|
|
|
|
zoom: 1
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const res = await fetch('?fetch=1')
|
|
|
|
|
|
|
|
.then((res) => res.json())
|
|
|
|
|
|
|
|
console.log(`Found ${res.total} pages of peers to fetch`)
|
|
|
|
|
|
|
|
fetchWithDelay(res.total, 1500);
|
|
|
|
|
|
|
|
|
|
|
|
// Setup popup
|
|
|
|
// Setup popup
|
|
|
|
var popup = new ol.Overlay({
|
|
|
|
var popup = new ol.Overlay({
|
|
|
|