YM4R with multiple domains

2009 March 2
by Nick

I didn’t find this option documented anywhere until I started digging through the code within the library. I had an instance where I was using A CMS to run multiple sites that all needed a use for google maps. With the regular implementation of YM4R you would normally get an error from google maps stating that this Google Maps API key isn’t valid for this domain. By simply passing in the host option you can then use the additional api keys you have setup in your config/gmaps_api_key.yml

In your config/gmaps_api_key.yml there needs to be a key for each domain that you wish to have google maps on.

production:
 host.com: longapikeythatmakesnosense
 anotherhost.com: jsdkfljskfljsgklsjgkl

Then in your layout file you need to print out the correct API key for communicating with google maps. This can be done by just passing in the host option with the request.host as it’s value.

One Response leave one →
  1. November 9, 2009

    I believe you meant gmaps_api_key.yml.

    By the way, thanks for the solution–It was just what I was looking for :)

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS