Skip to content

Commit 2ab9029

Browse files
committed
- (Bug Fix) Fixed an issue with a malformed url error being called
1 parent edbc908 commit 2ab9029

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

services/GoogleMaps_TemplatesService.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@ class GoogleMaps_TemplatesService extends BaseApplicationComponent
55
{
66
public function scripts()
77
{
8-
craft()->templates->includeJsFile('//maps.google.com/maps/api/js?sensor=true&libraries=geometry');
8+
if($this->isSecure())
9+
{
10+
$protocol = 'https://';
11+
}
12+
else
13+
{
14+
$protocol = 'http://';
15+
}
16+
17+
craft()->templates->includeJsFile($protocol . 'maps.google.com/maps/api/js?sensor=true&libraries=geometry');
918
craft()->templates->includeJsResource('googlemaps/js/vendor/base.js');
1019
craft()->templates->includeJsResource('googlemaps/js/vendor/underscore.js');
1120
craft()->templates->includeJsResource('googlemaps/js/vendor/markerclusterer.js');
@@ -174,4 +183,12 @@ public function jsonEncode($data)
174183
return str_replace(array('"', '\''), '', $match[0]);
175184
}, json_encode($data));
176185
}
186+
187+
public function isSecure()
188+
{
189+
return
190+
(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
191+
|| $_SERVER['SERVER_PORT'] == 443;
192+
}
193+
177194
}

0 commit comments

Comments
 (0)