when I'm on an https page in Chrome (and occasionally in Firefox) I am thrown a console error about a protocol mismatch. The maps.googleapis.com/maps/api/js?sensor=false script is blocked because of insecure content.

perhaps the protocol can be stripped from line 323 and 328 of google_map_field.module. I've tested this in chrome, safari, FF, and IE (9 & 10).

function google_map_field_add_maps_api() {
  if (variable_get('google_map_field_apikey', '') != '') {
    $element = array(
      '#type' => 'markup',
      '#markup' => '<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=false&key=' . variable_get('google_map_field_apikey', '') . '"></script>',
    );
    drupal_add_html_head($element, 'google_maps_api');
  }
  else {
    drupal_add_js('//maps.googleapis.com/maps/api/js?sensor=false', 'external');
  }
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

willito’s picture

a patch with the above change

scot.hubbard’s picture

Status: Active » Closed (fixed)

Please upgrade to version 7.x-2.4

matej.lehotsky’s picture

Version: 7.x-2.3 » 7.x-2.19
Issue summary: View changes
Status: Closed (fixed) » Active

With some ngnix server configuration is current protocol detection insufficient. Please use something like this instead...

function google_map_field_get_protocol() {
  return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
}
matej.lehotsky’s picture

scot.hubbard’s picture

Hi raweez

I have committed your patch to the current dev snapshot. Once it is available, feel free to close this ticket, or mark as tested and I'll make another stable release.

matej.lehotsky’s picture

Status: Active » Closed (fixed)
arne_hortell’s picture

In my case it should be like this

function google_map_field_get_protocol() {
return (!empty($GLOBALS['base_root']) && strpos($GLOBALS['base_root'],'https://')==0) ? "https://" : "http://";
}

Reason is because if working below a load balancer, everything set in $_SERVER is according to loadbalancer but base_root is not.