diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-10-19 11:07:45 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:23:19 +0100 | 
| commit | 13a3311ff045b53dbdced2b03dce7295d3c1a398 (patch) | |
| tree | ec0ce3d3ab0f7f5c9cc989b131405c327237138e /ishtar_common/static/js/ishtar-map.js | |
| parent | 4d2730f4003347eab7c25a5f0b3f01918e522d5a (diff) | |
| download | Ishtar-13a3311ff045b53dbdced2b03dce7295d3c1a398.tar.bz2 Ishtar-13a3311ff045b53dbdced2b03dce7295d3c1a398.zip | |
Geodata - Sheet : zoom to extent
Diffstat (limited to 'ishtar_common/static/js/ishtar-map.js')
| -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;          }      ) | 
