From 3174df0d16703988661d785a2fb4f02bcf5ad751 Mon Sep 17 00:00:00 2001 From: elias couppe Date: Fri, 15 Mar 2024 22:27:30 +0100 Subject: [PATCH] =?UTF-8?q?fix(ol:Controls):=20affichage=20plus=20fin=20de?= =?UTF-8?q?s=20r=C3=A9sultats=20de=20geocodage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/Utils/GeocodeUtils.js | 15 ++++++++++++++- src/OpenLayers/Controls/LayerImport.js | 10 ++++------ src/OpenLayers/Controls/SearchEngine.js | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Common/Utils/GeocodeUtils.js b/src/Common/Utils/GeocodeUtils.js index 992a1efa0..291c4b00e 100644 --- a/src/Common/Utils/GeocodeUtils.js +++ b/src/Common/Utils/GeocodeUtils.js @@ -10,7 +10,20 @@ var GeocodeUtils = { if (attributes.label) { return attributes.label; } else if (geocodedLocation.type === "PositionOfInterest") { - return attributes.postcode + " " + attributes.toponym; + var resultToReturn = attributes.toponym; + if (attributes.category && Array.isArray(attributes.category) && attributes.category.length >= 2 && attributes.category[0] === "administratif") { + // gestion particulière des territoires administratifs + resultToReturn = resultToReturn + ", " + attributes.category[1]; + } else { + // gestion standard des POI non adminsitratifs + if (attributes.postcode) { + resultToReturn = resultToReturn + ", " + attributes.postcode[0]; + if (attributes.city) { + resultToReturn = resultToReturn + " " + attributes.city[0]; + } + } + } + return resultToReturn; } else if (geocodedLocation.type === "StreetAddress") { return (attributes.housenumber ? attributes.housenumber + " " : "") + attributes.street + " " + (attributes.postcode ? attributes.postcode + ", " : "") + attributes.city; } else if (geocodedLocation.type === "CadastralParcel") { diff --git a/src/OpenLayers/Controls/LayerImport.js b/src/OpenLayers/Controls/LayerImport.js index 4f21d30f5..9e01cec2a 100644 --- a/src/OpenLayers/Controls/LayerImport.js +++ b/src/OpenLayers/Controls/LayerImport.js @@ -1227,9 +1227,8 @@ var LayerImport = (function (Control) { vectorSource = new VectorTileSource({ attributions : _glSource.attribution, format : vectorFormat, - // INFO - // on supprime la grille pour forcer l'utilisation par defaut des tuiles en 512 - // sur du vecteur tuilé + // INFO + // surcharge : grille en 256 sur du vecteur tuilé tileGrid : olCreateXYZTileGrid({ // TODO scheme tms ? extent : _glSource.bounds, // [minx, miny, maxx, maxy] maxZoom : _glSource.maxzoom || 22, @@ -1295,9 +1294,8 @@ var LayerImport = (function (Control) { vectorSource = new VectorTileSource({ attributions : vectorTileJson.getAttributions() || _tileJSONDoc.attribution, format : vectorFormat, - // INFO - // on supprime la grille pour forcer l'utilisation par defaut des tuiles en 512 - // sur du vecteur tuilé + // INFO + // surcharge : grille en 256 sur du vecteur tuilé tileGrid : olCreateXYZTileGrid({ // TODO scheme tms ? extent : _glSource.bounds, // [minx, miny, maxx, maxy] maxZoom : _glSource.maxzoom || 22, diff --git a/src/OpenLayers/Controls/SearchEngine.js b/src/OpenLayers/Controls/SearchEngine.js index b2981a42f..44f5bbc44 100644 --- a/src/OpenLayers/Controls/SearchEngine.js +++ b/src/OpenLayers/Controls/SearchEngine.js @@ -227,7 +227,7 @@ var SearchEngine = (function (Control) { // merge with user options Utils.mergeParams(this.options, options); if (this.options.resources.geocode === "") { - this.options.resources.geocode = "poi"; + this.options.resources.geocode = "address,poi"; } if (this.options.resources.autocomplete.length === 0) { this.options.resources.autocomplete = ["PositionOfInterest", "StreetAddress"];