diff --git a/DRAFT_CHANGELOG.md b/DRAFT_CHANGELOG.md index e541abc39..182da7b33 100644 --- a/DRAFT_CHANGELOG.md +++ b/DRAFT_CHANGELOG.md @@ -1,10 +1,5 @@ - - - - - # Extension Geoportail OpenLayers, version __VERSION__ **__DATE__** @@ -12,6 +7,8 @@ ## Summary +- Ajout d'exemples avec l'appel de *Gp.Services.getConfig()* + ## Changelog * [Added] @@ -30,7 +27,6 @@ - # Extension Geoportail Leaflet, version __VERSION__ **__DATE__** @@ -38,6 +34,8 @@ ## Summary +- Ajout d'exemples avec l'appel de *Gp.Services.getConfig()* + ## Changelog * [Added] @@ -50,13 +48,14 @@ * [Fixed] + - Fix sur les exemples avec un appel de *Gp.Services.getConfig()* + * [Security] --- - # Extension Geoportail Itowns, version __VERSION__ **__DATE__** diff --git a/samples-src/pages/leaflet/Default/pages-leaflet-bundle-getconfig.html b/samples-src/pages/leaflet/Default/pages-leaflet-bundle-getconfig.html new file mode 100644 index 000000000..3db049c2c --- /dev/null +++ b/samples-src/pages/leaflet/Default/pages-leaflet-bundle-getconfig.html @@ -0,0 +1,53 @@ +{{#extend "layout-leaflet-sample-bundle-getconfig"}} + +{{#content "head"}} + Sample Leaflet +{{/content}} + +{{#content "style"}} + +{{/content}} + +{{#content "body"}} +

Ajout de tous les widgets

+ +
+{{/content}} + +{{#content "js"}} + // on cache l'image de chargement du Géoportail. + document.getElementById("map").style.backgroundImage = "none"; + + // Création de la map + var layer = L.geoportalLayer.WMTS({ + layer : "ORTHOIMAGERY.ORTHOPHOTOS" + }); + + var map = L.map('map', { + zoom : 2, + center : L.latLng(48, 2) + }); + + layer.addTo(map); + + var iso = L.geoportalControl.Isocurve(); + map.addControl(iso); + var layerSwitcher = L.geoportalControl.LayerSwitcher(); + map.addControl(layerSwitcher); + var mp = L.geoportalControl.MousePosition(); + map.addControl(mp); + var route = L.geoportalControl.Route(); + map.addControl(route); + var reverse = L.geoportalControl.ReverseGeocode(); + map.addControl(reverse); + var search = L.geoportalControl.SearchEngine(); + map.addControl(search); + var measureProfil = L.geoportalControl.ElevationPath(); + map.addControl(measureProfil); +{{/content}} +{{/extend}} diff --git a/samples-src/pages/openlayers/Default/pages-ol-bundle-getconfig.html b/samples-src/pages/openlayers/Default/pages-ol-bundle-getconfig.html new file mode 100644 index 000000000..8940dcd47 --- /dev/null +++ b/samples-src/pages/openlayers/Default/pages-ol-bundle-getconfig.html @@ -0,0 +1,78 @@ +{{#extend "ol-sample-bundle-getconfig-layout"}} + +{{#content "head"}} + Sample openlayers - multikeys +{{/content}} + +{{#content "style"}} + +{{/content}} + +{{#content "body"}} +

Ajout de tous les widgets

+ +
+
+{{/content}} + +{{#content "js"}} + // on cache l'image de chargement du Géoportail. + document.getElementById("map").style.backgroundImage = "none"; + + // Création de la map + var map = new ol.Map({ + target : "map", + layers : [ + new ol.layer.GeoportalWMTS({ + layer : "GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2" + }), + new ol.layer.GeoportalWMTS({ + layer : "GEOGRAPHICALGRIDSYSTEMS.ETATMAJOR40" + }), + new ol.layer.GeoportalWMTS({ + layer : "LIMITES_ADMINISTRATIVES_EXPRESS.LATEST" + }) + ], + view : new ol.View({ + center : [288074.8449901076, 6247982.515792289], + zoom : 13 + }) + }); + + var drawing = new ol.control.Drawing(); + map.addControl(drawing); + var iso = new ol.control.Isocurve(); + map.addControl(iso); + var layerImport = new ol.control.LayerImport(); + map.addControl(layerImport); + var layerSwitcher = new ol.control.LayerSwitcher(); + map.addControl(layerSwitcher); + var mp = new ol.control.GeoportalMousePosition(); + map.addControl(mp); + var route = new ol.control.Route(); + map.addControl(route); + var reverse = new ol.control.ReverseGeocode({}); + map.addControl(reverse); + var search = new ol.control.SearchEngine({}); + map.addControl(search); + var feature = new ol.control.GetFeatureInfo({}); + map.addControl(feature); + + var measureLength = new ol.control.MeasureLength(); + map.addControl(measureLength); + var measureArea = new ol.control.MeasureArea(); + map.addControl(measureArea); + var measureAzimuth = new ol.control.MeasureAzimuth(); + map.addControl(measureAzimuth); + var measureProfil = new ol.control.ElevationPath(); + map.addControl(measureProfil); + + var attributions = new ol.control.GeoportalAttribution(); + map.addControl(attributions); +{{/content}} +{{/extend}} diff --git a/samples-src/pages/openlayers/Default/pages-ol-bundle-multikeys.html b/samples-src/pages/openlayers/Default/pages-ol-bundle-multikeys.html index a6eb836b2..29065728e 100644 --- a/samples-src/pages/openlayers/Default/pages-ol-bundle-multikeys.html +++ b/samples-src/pages/openlayers/Default/pages-ol-bundle-multikeys.html @@ -23,7 +23,7 @@

Ajout de tous les widgets

{{#content "js"}} {{/content}} {{/extend}} diff --git a/samples-src/templates/leaflet/layout-leaflet-sample-bundle-getconfig.hbs b/samples-src/templates/leaflet/layout-leaflet-sample-bundle-getconfig.hbs new file mode 100644 index 000000000..911bbedf6 --- /dev/null +++ b/samples-src/templates/leaflet/layout-leaflet-sample-bundle-getconfig.hbs @@ -0,0 +1,45 @@ + + + + {{#extend "partials-common-head"}} + {{/extend}} + {{#extend "partials-leaflet-common-head"}} + {{/extend}} + {{#block "vendor"}} + {{/block}} + + {{#extend "partials-leaflet-bundle-getconfig-head"}} + {{/extend}} + + {{#block "head"}} + {{/block}} + {{#block "style"}} + {{/block}} + + + +

Extension Géoportail pour Leaflet (mode bundle)

+ + {{#block "body"}} + {{/block}} + + + + diff --git a/samples-src/templates/openlayers/ol-sample-bundle-getconfig-layout.hbs b/samples-src/templates/openlayers/ol-sample-bundle-getconfig-layout.hbs new file mode 100644 index 000000000..1594a21d8 --- /dev/null +++ b/samples-src/templates/openlayers/ol-sample-bundle-getconfig-layout.hbs @@ -0,0 +1,41 @@ + + + + {{#extend "partials-common-head"}} + {{/extend}} + {{#extend "partials-ol-common-head"}} + {{/extend}} + {{#block "vendor"}} + {{/block}} + {{#extend "partials-ol-bundle-getconfig-head"}} + {{/extend}} + + {{#block "head"}} + {{/block}} + {{#block "style"}} + {{/block}} + + + +

Extension Géoportail pour OpenLayers

+ + {{#block "body"}} + {{/block}} + + + + diff --git a/samples-src/templates/partials/leaflet/partials-leaflet-bundle-getconfig-head.hbs b/samples-src/templates/partials/leaflet/partials-leaflet-bundle-getconfig-head.hbs new file mode 100644 index 000000000..9726d2114 --- /dev/null +++ b/samples-src/templates/partials/leaflet/partials-leaflet-bundle-getconfig-head.hbs @@ -0,0 +1,4 @@ + + + + diff --git a/samples-src/templates/partials/openlayers/partials-ol-bundle-getconfig-head.hbs b/samples-src/templates/partials/openlayers/partials-ol-bundle-getconfig-head.hbs new file mode 100644 index 000000000..188c3df00 --- /dev/null +++ b/samples-src/templates/partials/openlayers/partials-ol-bundle-getconfig-head.hbs @@ -0,0 +1,5 @@ + + + + + diff --git a/src/Common/Utils/Config.js b/src/Common/Utils/Config.js index 55c403198..09e3032b7 100644 --- a/src/Common/Utils/Config.js +++ b/src/Common/Utils/Config.js @@ -23,6 +23,10 @@ var Config = { * @returns {Boolean} True if Config is loaded, false otherwise */ isConfigLoaded : function () { + // config already loaded ! + if (this.configuration && Object.keys(this.configuration).length !== 0) { + return true; + } var scope = typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : {}; if (scope.Gp && scope.Gp.Config && scope.Gp.Config.layers && Object.keys(scope.Gp.Config.layers).length !== 0) { /** ts-syntax */ (this.configuration) = scope.Gp.Config; diff --git a/src/Leaflet/Layers/LayerConfig.js b/src/Leaflet/Layers/LayerConfig.js index b63794b58..4fadde98c 100644 --- a/src/Leaflet/Layers/LayerConfig.js +++ b/src/Leaflet/Layers/LayerConfig.js @@ -21,6 +21,11 @@ var LayerConfig = { get : function (options) { var params = {}; + if (!Config.isConfigLoaded()) { + logger.warn("WARNING CONFIG_FAILED : config not loaded ?!"); + return; + } + // gestion des parametres params = Config.configuration.getLayerParams(options.layer, options.service); diff --git a/src/Leaflet/index.js b/src/Leaflet/index.js index 7c6ef13f5..845514716 100644 --- a/src/Leaflet/index.js +++ b/src/Leaflet/index.js @@ -102,7 +102,9 @@ export { default as ProxyUtils } from "../Common/Utils/ProxyUtils"; export { default as ColorUtils } from "../Common/Utils/ColorUtils"; export { default as MathUtils } from "../Common/Utils/MathUtils"; export { default as Logger } from "../Common/Utils/LoggerByDefault"; -export { default as Config } from "../Common/Utils/Config"; + +// HACK !? +export const Config = (window.Gp) ? window.Gp.Config : {}; // creation du namespace pour les extensions leaflet L.geoportalLayer = Layers; // WMS et WMTS