فهرست منبع

#1229 Don't store locally js files for Google Location Field

Alex Trofimov 8 سال پیش
والد
کامیت
814c232649
2فایلهای تغییر یافته به همراه11 افزوده شده و 3 حذف شده
  1. 9 2
      template/form_field_location.html
  2. 2 1
      template/scripts/BxBaseFormView.php

+ 9 - 2
template/form_field_location.html

@@ -15,6 +15,7 @@
 <input type="hidden" name="__name___street" value="__street__" />
 <input type="hidden" name="__name___street_number" value="__street_number__" />
 
+<script language="javascript" type="text/javascript" src="https://maps.google.com/maps/api/js?libraries=places&language=__lang__&key=__key__"></script>
 <script>
 
     var oBxLocationHashMap = {
@@ -120,8 +121,7 @@
         }
     });
 
-
-    $(document).ready(function () {
+    var fInitCallback = function () {
 
         var callbackFillInAddress = function () {
             // Get the place details from the autocomplete object.
@@ -153,6 +153,13 @@
             glBxAutocomplete__name__.addListener('place_changed', callbackFillInAddress);
         }
 
+    }
+    
+    $(document).ready(function () {        
+        if ('undefined' === typeof(google))
+            bx_get_scripts(['https://maps.google.com/maps/api/js?libraries=places&language=__lang__&key=__key__'], fInitCallback);
+        else
+            fInitCallback();
     });
 
 </script>

+ 2 - 1
template/scripts/BxBaseFormView.php

@@ -1193,9 +1193,10 @@ BLAH;
         $sIdStatus = $this->getInputId($aInput) . '_status';
         $sIdInput = $this->getInputId($aInput) . '_location';
         $sProto = (0 === strncmp('https', BX_DOL_URL_ROOT, 5)) ? 'https' : 'http';
-        $this->_addJs($sProto . '://maps.google.com/maps/api/js?libraries=places&language=' . bx_lang_name() . '&key=' . trim(getParam('sys_maps_api_key')));
 
         $aVars = array (
+            'key' => trim(getParam('sys_maps_api_key')),
+            'lang' => bx_lang_name(),
             'name' => $aInput['name'],
             'id_status' => $sIdStatus,
             'id_input' => $sIdInput,