开发者

Using gmaps4rails with https/SSL

I'm a big fan of gmaps4rails - it's made adding maps to our web app very easy. The only problem I'm hitting now is that if you use it on an https page, then you get security warnings about mixed content. The google maps api does support https, so I think it's just a question of changing the script references from http to https. Unfortunately I think it's hidden behind the "开发者_StackOverflow中文版acts_as_gmappable" statement - I was hoping for a content_for block I could modify.

Is there an easy way to make it use the https version of the API?

http://code.google.com/apis/maps/documentation/javascript/basics.html#HTTPS

Many thanks,

Alex


It's not a very obvious title but your solution lies in the Miscellaneous section of the gem's wiki.

Just have a look:

<%= gmaps( data_hash, enable_css, enable_js) %>

enable_css and enable_js are booleans.

So if you do:

<%= gmaps( data_hash, true, false) %>

It won't load any js. his way you can add whatever you want by yourself. Don't forget to include the gmaps4rails.js file!


For anyone who has a problem with the clustered markers, just change the image path of the cluster images before the initialisation of the handler:

    MarkerClusterer.IMAGE_PATH = 'https://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m';

I don't know if that's the best way, but at least it works and I hove no problem with SSL errors on my page because of the clustered markers anymore.

Update

Ok it is not the best way. Here's a better solution:

handler = Gmaps.build('Google', {
  markers: {
    clusterer: {
      imagePath: 'https://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m'
    }
  }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜