From e7ab9e498c17c4bc9e153bc94e97b7b872a97cbd Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Wed, 2 Aug 2017 20:14:31 +0200 Subject: [PATCH] fix google api changes --- www/plugins/es/js/services/geo-services.js | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/www/plugins/es/js/services/geo-services.js b/www/plugins/es/js/services/geo-services.js index c3d34f68..fc2c2374 100644 --- a/www/plugins/es/js/services/geo-services.js +++ b/www/plugins/es/js/services/geo-services.js @@ -126,23 +126,23 @@ angular.module('cesium.es.geo.services', ['cesium.services', 'cesium.es.http.ser }); } - // If no google api key in config: get it from settings that.raw.google.apiKey = csConfig.plugins && csConfig.plugins.es && csConfig.plugins.es.googleApiKey; - if (!that.raw.google.apiKey) { - csSettings.ready() - .then(function() { - - // Listen settings changed - function onSettingsChanged(data){ - that.raw.google.enable = data.plugins && data.plugins.es && data.plugins.es.enableGoogleApi; - that.raw.google.apiKey = that.raw.google.enable && data.plugins.es.googleApiKey; + var hasConfigApiKey = !!that.raw.google.apiKey; + csSettings.ready() + .then(function() { + + // Listen settings changed + function onSettingsChanged(data){ + if (!hasConfigApiKey) { + // If no google api key in config, use in settings + that.raw.google.apiKey = data.plugins.es.googleApiKey; } - csSettings.api.data.on.changed($rootScope, onSettingsChanged, this); - - onSettingsChanged(csSettings.data); - }); - } + that.raw.google.enable = that.raw.google.apiKey && data.plugins && data.plugins.es && data.plugins.es.enableGoogleApi; + } + csSettings.api.data.on.changed($rootScope, onSettingsChanged, this); + onSettingsChanged(csSettings.data); + }); return { point: { -- GitLab