summaryrefslogtreecommitdiff
path: root/ishtar_common/static/js/ishtar-map.js
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2022-10-14 12:46:27 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:23:19 +0100
commit019f9ec97f8fae2e8d9961b9d06e57b957735d2e (patch)
tree2c1b4b978b47eb54d5f0deaf8dc72e9b67feab59 /ishtar_common/static/js/ishtar-map.js
parent1a7c25095e39a0b666922f5c602906492e58e390 (diff)
downloadIshtar-019f9ec97f8fae2e8d9961b9d06e57b957735d2e.tar.bz2
Ishtar-019f9ec97f8fae2e8d9961b9d06e57b957735d2e.zip
Geodata: work on zoom to extent (hide HTML for the moment..)
Diffstat (limited to 'ishtar_common/static/js/ishtar-map.js')
-rw-r--r--ishtar_common/static/js/ishtar-map.js41
1 files changed, 39 insertions, 2 deletions
diff --git a/ishtar_common/static/js/ishtar-map.js b/ishtar_common/static/js/ishtar-map.js
index 3fbfd390a..2fce7f6e6 100644
--- a/ishtar_common/static/js/ishtar-map.js
+++ b/ishtar_common/static/js/ishtar-map.js
@@ -664,7 +664,7 @@ var initialize_base_map = function(map_id, layers){
})
];
- console.log(map_id);
+ // console.log(map_id);
map_view[map_id] = new ol.View({
projection: view_projection,
center: ol.proj.fromLonLat([center[0], center[1]]),
@@ -887,9 +887,37 @@ const refresh_map = function(idx, geodata_list, url, attrs) {
if (geo_type === 'POINT'){
Array.prototype.push.apply(
_geo_points[idx]["features"], geojson["features"]);
+ if (_geo_extents[idx].indexOf(key) === -1){
+ _geo_extents[key] = new ol.geom.Circle(
+ ol.proj.transform(geojson["features"][0]["geometry"]["coordinates"], 'EPSG:4326', 'EPSG:3857'),
+ 1000
+ ).getExtent();
+ _geo_extents[key] = new ol.geom.Circle(
+ geojson["features"][0]["geometry"]["coordinates"],
+ 0.01
+ ).getExtent();
+ _geo_extents[key] = [parseFloat(_geo_extents[key][0]),
+ parseFloat(_geo_extents[key][1]),
+ parseFloat(_geo_extents[key][2]),
+ parseFloat(_geo_extents[key][3])];
+ // console.log(key);
+ // console.log(_geo_extents[key]);
+ // console.log(_geo_extents[key][0]);
+ register_zoom_on_map("#map-zoom-" + key);
+
+
+ }
} else {
Array.prototype.push.apply(
_geo_other[idx]["features"], geojson["features"]);
+ if (_geo_extents[idx].indexOf(key) === -1){
+ let feat = BASE_GEOJSON;
+ feat["features"] = geojson["features"];
+ _geo_extents[key] = new ol.source.Vector(
+ {features: new ol.format.GeoJSON().readFeatures(feat)}
+ ).getExtent();
+ register_zoom_on_map("#map-zoom-" + key);
+ }
}
if (_geo_extents[idx].indexOf(key) === -1){
let feat = BASE_GEOJSON;
@@ -912,12 +940,21 @@ const refresh_map = function(idx, geodata_list, url, attrs) {
}
}
+var click_delay;
+
const register_zoom_on_map = function(){
$(".map-zoom-link").click(
function(){
+ if (click_delay && (Date.now() - click_delay) < 1000){
+ click_delay = Date.now();
+ return false;
+ }
+ click_delay = Date.now();
let feat_key = $(this).attr("data-geo-id");
let map_idx = $(this).attr("data-map-id");
- /// console.log(_geo_extents[feat_key]);
+ console.log(feat_key);
+ console.log(_geo_extents[feat_key]);
+ console.log(_geo_extents[feat_key][0]);
map_view[map_idx].fit(_geo_extents[feat_key]);
return false;
}