Google map api with ym4r

November 2 2010

In development, the application was working fine. And because the ym4r plugin has yet to implement the Google maps api version 3, I made sure to include the appropriate api key for the domain in the config.

In production however, the page was failing. Fortunately Hoptoad alerted me of the following error - Ym4r::GmPlugin::AmbiguousGMapsAPIKeyException.

It turns out that ym4r was having difficulty choosing a specific host in my gmaps_api_key.yml file, as I had multiple set up for the various domains the site is hosted on. To rectify this I ended up changing the declaration at the top of my layout file, which loads the google maps api into the page, from

<%= GMap.header %>

to

<%= GMap.header(:with_vml => false, :host => request.host) %>