From 0041a67360e0a397f1afcd9fb63a94c3ca72d296 Mon Sep 17 00:00:00 2001 From: Duchateau Fabien <fabien.duchateau@univ-lyon1.fr> Date: Mon, 4 Feb 2019 09:39:42 +0100 Subject: [PATCH] minor modif parameters --- mapiris/static/js/carto.js | 8 +++++--- mapiris/static/js/utils.js | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mapiris/static/js/carto.js b/mapiris/static/js/carto.js index 449aca0..37cb96d 100644 --- a/mapiris/static/js/carto.js +++ b/mapiris/static/js/carto.js @@ -79,17 +79,19 @@ function resetHighlightAll() { * @param {geojson} geojson . * @param {event} events . * @param {object} style . + * @param {string} typeMethod . (specify the method which caused this display, ex "searchBounds", "searchCode", "searchName") * @param {function} callback . */ -function addLayerFromGeoJSON(geojson, events, style){ - if(irisLayer !== null) { // if already displayed iris, remove them +function addLayerFromGeoJSON(geojson, events, style, typeMethod){ + if(irisLayer != null) { // if already displayed iris, remove them removeLayer(irisLayer); } if(geojson != null) { irisLayer = new L.geoJSON(geojson, {onEachFeature: events}); irisLayer.setStyle(style); irisLayer.addTo(map); - map.fitBounds(irisLayer.getBounds()); // zoom on the displayed iris + if(typeMethod != "searchBounds") // if searchBounds (zoom), fitBounds() will decrease the zoom, thus reloading searchBounds... + map.fitBounds(irisLayer.getBounds()); // zoom on the displayed iris } // todo add markers ? return irisLayer; diff --git a/mapiris/static/js/utils.js b/mapiris/static/js/utils.js index 87bc572..dec99fe 100644 --- a/mapiris/static/js/utils.js +++ b/mapiris/static/js/utils.js @@ -27,7 +27,7 @@ function getIrisFromCode(e) { contentType: 'application/json;charset=UTF-8', success: function(result){ jsonResult = JSON.parse(result); - irisLayer = addLayerFromGeoJSON(jsonResult['geojson'], eventsIRIS, styleDisplayedIris); + irisLayer = addLayerFromGeoJSON(jsonResult['geojson'], eventsIRIS, styleDisplayedIris, "searchCode"); refreshMessages(); }, error: function(result, textStatus, errorThrown) { @@ -52,7 +52,7 @@ function getIrisFromName(e) { contentType: 'application/json;charset=UTF-8', success: function(result){ jsonResult = JSON.parse(result); - irisLayer = addLayerFromGeoJSON(jsonResult['geojson'], eventsIRIS, styleDisplayedIris); + irisLayer = addLayerFromGeoJSON(jsonResult['geojson'], eventsIRIS, styleDisplayedIris, "searchName"); refreshMessages(); }, error: function(result, textStatus, errorThrown) { @@ -81,7 +81,7 @@ function getIrisForBounds(areaBounds) { contentType: 'application/json;charset=UTF-8', success: function(result){ jsonResult = JSON.parse(result); - irisLayer = addLayerFromGeoJSON(jsonResult['geojson'], eventsIRIS, styleDisplayedIris); + irisLayer = addLayerFromGeoJSON(jsonResult['geojson'], eventsIRIS, styleDisplayedIris, "searchBounds"); refreshMessages(); }, error: function(result, textStatus, errorThrown) { -- GitLab