| @@ -115,15 +115,22 @@ | ||
| 115 | 115 | * |
| 116 | 116 | * @param mixed string or array values values to append to the URL. |
| 117 | 117 | * |
| 118 | 118 | * @return self |
| 119 | + * | |
| 120 | + * @since 1.18.3 (J) - 1.8.3 (WP) loaded file gmaps-utils.js. | |
| 119 | 121 | */ |
| 120 | 122 | public function loadAssets($params = null) |
| 121 | 123 | { |
| 122 | - if (empty($this->gmaps_apikey)) { | |
| 124 | + static $loaded = null; | |
| 125 | + | |
| 126 | + if (empty($this->gmaps_apikey) || $loaded) { | |
| 123 | 127 | return $this; |
| 124 | 128 | } |
| 125 | 129 | |
| 130 | + // turn flag on | |
| 131 | + $loaded = true; | |
| 132 | + | |
| 126 | 133 | // values like &callback=initMap could be passed as argument |
| 127 | 134 | $qstring = ''; |
| 128 | 135 | |
| 129 | 136 | if (!empty($params)) { |
| @@ -128,16 +135,20 @@ | ||
| 128 | 135 | |
| 129 | 136 | if (!empty($params)) { |
| 130 | 137 | if (is_string($params)) { |
| 131 | 138 | $qstring = (substr($params, 0, 1) != '&' ? '&' : '') . $params; |
| 132 | - } | |
| 133 | - if (is_array($params)) { | |
| 139 | + } elseif (!is_scalar($params)) { | |
| 134 | 140 | $qstring = '&' . http_build_query($params); |
| 135 | 141 | } |
| 136 | 142 | } |
| 137 | 143 | |
| 144 | + $document = JFactory::getDocument(); | |
| 145 | + | |
| 146 | + // load the Google Maps Utils file within VikBooking | |
| 147 | + $document->addScript(VBO_SITE_URI . 'resources/gmaps-utils.js', ['version' => VIKBOOKING_SOFTWARE_VERSION]); | |
| 148 | + | |
| 138 | 149 | // load Google Maps API JS |
| 139 | - JFactory::getDocument()->addScript('https://maps.googleapis.com/maps/api/js?key=' . $this->gmaps_apikey . $qstring); | |
| 150 | + $document->addScript('https://maps.googleapis.com/maps/api/js?key=' . $this->gmaps_apikey . $qstring); | |
| 140 | 151 | |
| 141 | 152 | return $this; |
| 142 | 153 | } |
| 143 | 154 | |