Skip to content

Commit

Permalink
Merge pull request #23 from ClickHouse/fix-20
Browse files Browse the repository at this point in the history
Fix #20
  • Loading branch information
alexey-milovidov authored May 5, 2024
2 parents 9b18c0e + 19df38d commit 67231f5
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,15 @@
opacity: 0.1,
});

let map = L.map('map', {
center: [52.3676, 4.9041],
zoom: 5,
worldCopyJump: true,
layers: [base_layer]
});

map.attributionControl.setPrefix('<a href="https://github.com/ClickHouse/adsb.exposed/">About</a>');

let query_elem = document.getElementById('query');
let map_elem = document.getElementById('map');
let selected_box = [];
Expand All @@ -358,20 +367,23 @@

function collapseQueryEditor() {
query_elem.style.height = '4.5em';
query_elem.blur();
}

function updateMap() {
let selected_example = document.querySelector('#examples .selected');
if (selected_example && query_elem.value != queries[selected_example.textContent]) {
selected_example.classList.remove('selected');
}

query_elem.blur();
main_layer_sample100.redraw();
if (selected_box.length == 2) showReport();
}

function setQuery(value) {
query_elem.value = value;
collapseQueryEditor();
updateMap();
}

for (elem of document.querySelectorAll('#examples span')) {
Expand All @@ -386,12 +398,14 @@

query_elem.addEventListener('input', expandQueryEditor);
query_elem.addEventListener('focus', expandQueryEditor);
query_elem.addEventListener('blur', updateMap);
map_elem.addEventListener('focus', collapseQueryEditor);

query_elem.addEventListener('keydown', e => {
/// Firefox has code 13 for Enter and Chromium has code 10.
if ((event.metaKey || event.ctrlKey) && (event.keyCode == 13 || event.keyCode == 10)) {
collapseQueryEditor();
updateMap();
}
});

Expand Down Expand Up @@ -465,7 +479,7 @@

document.querySelector('form').addEventListener('change', e => {
cached_tiles = {};
main_layer_sample100.redraw();
updateMap();
});

/// Rendering
Expand All @@ -479,9 +493,6 @@

if (!cached_tiles[key]) cached_tiles[key] = [];

/// If there is a higer-detail tile, skip rendering of this level of detal.
if (cached_tiles[key][priority + 1]) return;

buf = cached_tiles[key][priority];

if (!buf) {
Expand Down Expand Up @@ -560,15 +571,6 @@

setQuery(queries[document.querySelector('#examples .selected').textContent]);

let map = L.map('map', {
center: [52.3676, 4.9041],
zoom: 5,
worldCopyJump: true,
layers: [base_layer]
});

map.attributionControl.setPrefix('<a href="https://github.com/ClickHouse/adsb.exposed/">About</a>');

/// Restore from a saved link

function latlngToMercator(latlng) {
Expand All @@ -589,7 +591,6 @@
loadQuery(hash).then(query => {
query_elem.value = query;
map.setView({lat: params.get('lat'), lng: params.get('lng')}, params.get('zoom'));
collapseQueryEditor();
});
} else {
map.setView({lat: params.get('lat'), lng: params.get('lng')}, params.get('zoom'));
Expand All @@ -608,10 +609,10 @@
}
}

/// Sequential loading for different levels of details

main_layer_sample100.addTo(map);

/// Sequential loading for different levels of details

main_layer_sample100.on('load', e => {
main_layer_sample10.addTo(map);
document.documentElement.style.setProperty('--progress-background-color', 'var(--progress-background-color2)');
Expand Down

0 comments on commit 67231f5

Please sign in to comment.