diff options
Diffstat (limited to 'ishtar_common/static')
-rw-r--r-- | ishtar_common/static/js/ishtar-map.js | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/ishtar_common/static/js/ishtar-map.js b/ishtar_common/static/js/ishtar-map.js index 2fce7f6e6..394b27feb 100644 --- a/ishtar_common/static/js/ishtar-map.js +++ b/ishtar_common/static/js/ishtar-map.js @@ -892,20 +892,7 @@ const refresh_map = function(idx, geodata_list, url, attrs) { 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( @@ -913,21 +900,18 @@ const refresh_map = function(idx, geodata_list, url, attrs) { 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)} + let extent = new ol.source.Vector( + {features: new ol.format.GeoJSON().readFeatures(feat)} ).getExtent(); + let coords_1 = ol.proj.transform([extent[0], extent[1]], 'EPSG:4326', 'EPSG:3857'); + let coords_2 = ol.proj.transform([extent[2], extent[3]], 'EPSG:4326', 'EPSG:3857'); + _geo_extents[key] = [ + coords_1[0], coords_1[1], + coords_2[0], coords_2[1] + ]; register_zoom_on_map("#map-zoom-" + key); } } - 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(); - /// console.log(_geo_extents[key]); - register_zoom_on_map("#map-zoom-" + key); - } $("#map-zoom-" + key).attr('aria-disabled', 'false'); } else { $("#map-zoom-" + key).attr('aria-disabled', 'true'); @@ -952,10 +936,9 @@ const register_zoom_on_map = function(){ click_delay = Date.now(); let feat_key = $(this).attr("data-geo-id"); let map_idx = $(this).attr("data-map-id"); - 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]); + if (! ol.extent.isEmpty(_geo_extents[feat_key])) { + map_view[map_idx].fit(_geo_extents[feat_key]); + } return false; } ) |