Skip to content
Snippets Groups Projects
Commit 0041a673 authored by Duchateau Fabien's avatar Duchateau Fabien
Browse files

minor modif parameters

parent 1679ebb0
No related branches found
No related tags found
No related merge requests found
...@@ -79,17 +79,19 @@ function resetHighlightAll() { ...@@ -79,17 +79,19 @@ function resetHighlightAll() {
* @param {geojson} geojson . * @param {geojson} geojson .
* @param {event} events . * @param {event} events .
* @param {object} style . * @param {object} style .
* @param {string} typeMethod . (specify the method which caused this display, ex "searchBounds", "searchCode", "searchName")
* @param {function} callback . * @param {function} callback .
*/ */
function addLayerFromGeoJSON(geojson, events, style){ function addLayerFromGeoJSON(geojson, events, style, typeMethod){
if(irisLayer !== null) { // if already displayed iris, remove them if(irisLayer != null) { // if already displayed iris, remove them
removeLayer(irisLayer); removeLayer(irisLayer);
} }
if(geojson != null) { if(geojson != null) {
irisLayer = new L.geoJSON(geojson, {onEachFeature: events}); irisLayer = new L.geoJSON(geojson, {onEachFeature: events});
irisLayer.setStyle(style); irisLayer.setStyle(style);
irisLayer.addTo(map); 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 ? // todo add markers ?
return irisLayer; return irisLayer;
......
...@@ -27,7 +27,7 @@ function getIrisFromCode(e) { ...@@ -27,7 +27,7 @@ function getIrisFromCode(e) {
contentType: 'application/json;charset=UTF-8', contentType: 'application/json;charset=UTF-8',
success: function(result){ success: function(result){
jsonResult = JSON.parse(result); jsonResult = JSON.parse(result);
irisLayer = addLayerFromGeoJSON(jsonResult['geojson'], eventsIRIS, styleDisplayedIris); irisLayer = addLayerFromGeoJSON(jsonResult['geojson'], eventsIRIS, styleDisplayedIris, "searchCode");
refreshMessages(); refreshMessages();
}, },
error: function(result, textStatus, errorThrown) { error: function(result, textStatus, errorThrown) {
...@@ -52,7 +52,7 @@ function getIrisFromName(e) { ...@@ -52,7 +52,7 @@ function getIrisFromName(e) {
contentType: 'application/json;charset=UTF-8', contentType: 'application/json;charset=UTF-8',
success: function(result){ success: function(result){
jsonResult = JSON.parse(result); jsonResult = JSON.parse(result);
irisLayer = addLayerFromGeoJSON(jsonResult['geojson'], eventsIRIS, styleDisplayedIris); irisLayer = addLayerFromGeoJSON(jsonResult['geojson'], eventsIRIS, styleDisplayedIris, "searchName");
refreshMessages(); refreshMessages();
}, },
error: function(result, textStatus, errorThrown) { error: function(result, textStatus, errorThrown) {
...@@ -81,7 +81,7 @@ function getIrisForBounds(areaBounds) { ...@@ -81,7 +81,7 @@ function getIrisForBounds(areaBounds) {
contentType: 'application/json;charset=UTF-8', contentType: 'application/json;charset=UTF-8',
success: function(result){ success: function(result){
jsonResult = JSON.parse(result); jsonResult = JSON.parse(result);
irisLayer = addLayerFromGeoJSON(jsonResult['geojson'], eventsIRIS, styleDisplayedIris); irisLayer = addLayerFromGeoJSON(jsonResult['geojson'], eventsIRIS, styleDisplayedIris, "searchBounds");
refreshMessages(); refreshMessages();
}, },
error: function(result, textStatus, errorThrown) { error: function(result, textStatus, errorThrown) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment