This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit 81654fc155c2d6d54914b4daf731525271be71ad
Author: Jacques Le Roux <jacques.le.r...@les7arts.com>
AuthorDate: Sat May 29 12:52:18 2021 +0200

    Improved: Allow to pass a Google API key for geolocation (OFBIZ-12247)
    
    Better way to handle a missing Google API key
---
 .../common-theme/template/includes/GeoLocation.ftl | 23 +++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/themes/common-theme/template/includes/GeoLocation.ftl 
b/themes/common-theme/template/includes/GeoLocation.ftl
index e840487..d265a88 100644
--- a/themes/common-theme/template/includes/GeoLocation.ftl
+++ b/themes/common-theme/template/includes/GeoLocation.ftl
@@ -35,14 +35,19 @@ under the License.
   </#if>
 
 <#-- ================================= Google Maps Init 
======================================-->
-  <#assign googleApiKey = 
Static["org.apache.ofbiz.entity.util.EntityUtilProperties"].getPropertyValue("general",
 "googleApiKey", delegator)>
-  <#if geoChart.dataSourceId?has_content && googleApiKey?has_content>
+  <#if geoChart.dataSourceId?has_content>
     <#if "GOOGLE" == 
geoChart.dataSourceId?substring(geoChart.dataSourceId?length-6 , 
geoChart.dataSourceId?length)>
-      <div id="${id}"
-        style="border:1px solid #979797; background-color:#e5e3df; 
width:${geoChart.width}; height:${geoChart.height}; margin:2em auto;">
-        <div style="padding:1em; color:gray;">${uiLabelMap.CommonLoading}</div>
-      </div>
-      <script src="https://maps.googleapis.com/maps/api/js?key=googleApiKey"; 
type="application/javascript"></script>
+        <#assign googleApiKey = 
Static["org.apache.ofbiz.entity.util.EntityUtilProperties"].getPropertyValue("general",
 "googleApiKey", delegator)>
+          <div id="${id}"
+            style="border:1px solid #979797; background-color:#e5e3df; 
width:${geoChart.width}; height:${geoChart.height}; margin:2em auto;">
+            <div style="padding:1em; 
color:gray;">${uiLabelMap.CommonLoading}</div>
+          </div>
+        <#if !googleApiKey?has_content>
+          <h2>${uiLabelMap.CommonNoGoogleAPIkeyAvailable}</h2>
+          <script src="https://maps.googleapis.com/maps/api/js"; 
type="application/javascript"></script>
+        <#else>
+          <script 
src="https://maps.googleapis.com/maps/api/js?key=googleApiKey"; 
type="application/javascript"></script>
+        </#if>
     </#if>
   <#-- ========================== Here we go with different types of maps 
renderer ===========================-->
     <#if "GEOPT_GOOGLE" == geoChart.dataSourceId>
@@ -178,7 +183,3 @@ under the License.
 <#else>
   <h2>${uiLabelMap.CommonNoGeolocationAvailable}</h2>
 </#if>
-
-<#if !googleApiKey?has_content>
-  <h2>${uiLabelMap.CommonNoGoogleAPIkeyAvailable}</h2>
-</#if>

Reply via email to