diff options
-rw-r--r-- | CHANGES.md | 8 | ||||
-rw-r--r-- | ishtar_common/static/js/ishtar-map.js | 41 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/sheet_map.html | 4 |
3 files changed, 49 insertions, 4 deletions
diff --git a/CHANGES.md b/CHANGES.md index b3de7a5db..2a830ec39 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,14 @@ title: Ishtar changelog date: 2022-10-03 --- +### Features ### +- + +### Bug fix ### + +- Geo data: fix main_geodata association test + + v4.0.20 - 2022-10-03 -------------------- 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; } diff --git a/ishtar_common/templates/ishtar/blocks/sheet_map.html b/ishtar_common/templates/ishtar/blocks/sheet_map.html index 70832e1a1..50ebbd85d 100644 --- a/ishtar_common/templates/ishtar/blocks/sheet_map.html +++ b/ishtar_common/templates/ishtar/blocks/sheet_map.html @@ -9,13 +9,13 @@ <h4>{% trans "Geographic data" %}</h4> <ul>{% for geodata in geodata_list %} <li> - <a role="link" href="#" aria-disabled="true" class="map-zoom-link" + <!-- <a role="link" href="#" aria-disabled="true" class="map-zoom-link" id="map-zoom-{{geo_item.SLUG}}-{{geo_item.pk}}-{{geodata.pk}}" data-map-id="map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}" data-geo-id="{{geo_item.SLUG}}-{{geo_item.pk}}-{{geodata.pk}}" > <i class="fa fa-search" aria-hidden="true"></i> - </a> + </a> --> <input type="checkbox" name="map-ol-{{geo_item.SLUG}}-{{geo_item.pk}}-{{geodata.pk}}" class="map-ol-{{geo_item.SLUG}}-{{geo_item.pk}}" id="map-ol-{{geo_item.SLUG}}-{{geo_item.pk}}-{{geodata.pk}}" |