diff options
Diffstat (limited to 'ishtar_common/static')
-rw-r--r-- | ishtar_common/static/js/ishtar-map.js | 41 |
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; } |