Hi!
When using the gmap module in conjunction with SSL (e.g. via the securepages module), leads to problems, since a script is loaded from maps.google.com/maps via plain http causing warnings in most browsers.
Since the Google maps service can't be accessed via https with the free api keys just replacing http with https won't work.
In our case, where no pages containing maps need to be access in a secure manner, the solution was to prevent adding the script to the html-header when the site is accesed via https. The attached patch solved the problem for us. It's kind of a hack; a better solution would be, if google's script would only be loaded, if it's needed on the page shown, but I didn't know how to do that.
Maybe it's useful for someone else, so I post it here.
Best regards and thanks for all the work,
Alexander
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | gmap-429330-3.patch | 1.3 KB | jsenich |
| #2 | gmap_429330.patch | 1.34 KB | ahojchris |
| gmap-nossl.patch | 567 bytes | tolimar |
Comments
Comment #1
christiaan_ commentedGoogle Maps APIs over SSL now available to all
http://googlegeodevelopers.blogspot.com/2011/03/maps-apis-over-ssl-now-a...
If you need your site to be secure and google maps to load over SSL change the following in the gmap.module file.
line: 329
drupal_set_html_head('<script src="'. check_url(url('https://maps-api-ssl.google.com/maps', array('query' => $query))) .'" type="text/javascript"></script>');line: 1112
$data = drupal_http_request('https://maps-api-ssl.google.' . $tld . '/maps/geo?q=' . drupal_urlencode($address) . '&output=csv&key=' . $key);You would also need to generate a new Google Maps API key for your SSL domain.
Comment #2
ahojchris commentedTaking inspiration from the above post, this patch adds a function (gmap_views_protocol) to check the current page protocol and returns a string of either 'http' or 'https' accordingly. This function is called on lines 329 and 1112 where the google map URIs are set. This patch does not address the fact that you need a different API key for http vs. https, so one still needs to use the same protocol consistently site-wide for all gmap content.
An additional improvement would be to add a secondary (optional) API field for SSL access and work that into line 1112.
Feedback?
Comment #3
jsenich commentedThis is needed in 7.x as well.
Comment #4
jsenich commentedPatch against 7.x-1.x-dev.
Comment #5
mcpuddin commentedWorks well for me on Drupal 6
Comment #6
vince@lacknergroup.com commentedUnsubscribe
Comment #7
mrfelton commentedPatch in #2 works for me. Though I had to add this in my settings.pgp file to allow me to use a different key on the HTTPS site:
Comment #8
catrina commentedThis patch worked for me on Drupal 7. Gmap.module version 7.x.-1.x-dev. Thank you!
Comment #9
christiaan_ commentedComment #10
markie commentedPatch #4 works and should be applied to the dev snapshot.
Comment #11
haiiro.shimeji commentedPatch #4 is applied to 7.x-1.x branch. Thanks a lot!
Comment #13
ice5nake commentedIs this fixed in the 6.x dev version? If it is fixed in dev, will this be pushed to the stable release anytime soon?