Initial commit
This commit is contained in:
commit
c4aa27e8f4
14 changed files with 1172 additions and 0 deletions
40
static/js/search_map.js
Normal file
40
static/js/search_map.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
'use strict';
|
||||
|
||||
// Create a map
|
||||
|
||||
var options = {};
|
||||
if (user_lat && user_lon) {
|
||||
options = {
|
||||
center: [user_lat, user_lon],
|
||||
zoom: 15,
|
||||
};
|
||||
}
|
||||
|
||||
var map = L.map("map", options);
|
||||
map.zoomControl.setPosition('topright');
|
||||
|
||||
if (!user_lat || !user_lon) {
|
||||
map.fitBounds([[49.85,-10.5], [58.75, 1.9]]);
|
||||
}
|
||||
|
||||
// Add OpenStreetMap layer
|
||||
var osm = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { maxZoom: 18 });
|
||||
|
||||
osm.addTo(map);
|
||||
|
||||
var hits = document.getElementsByClassName("hit-card");
|
||||
var current_hit = null;
|
||||
|
||||
for (const card of hits) {
|
||||
card.addEventListener('mouseover', event => {
|
||||
var id_string = card.id;
|
||||
if (current_hit == id_string) return;
|
||||
current_hit = id_string;
|
||||
var re_id = /^hit-card-(\d+)$/;
|
||||
var hit_index = re_id.exec(id_string)[1];
|
||||
var [south, north, west, east] = bbox_list[hit_index];
|
||||
var bounds = [[north, west], [south, east]];
|
||||
|
||||
map.fitBounds(bounds);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue