apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

'b' is undefined #109

Closed mgillesp closed 12 years ago

mgillesp commented 12 years ago

Hi there,

First and foremost, thank you for such a great rails gem for integrating Google Maps. I am just in love with this implementation!

Currently, I am trying to render a Gmap via the <%= gmap %> command, and everything goes well except I get the following javascript error:

b is undefined http://maps.gstatic.com/cat_js/intl/en_us/mapfiles/api-3/5/16/%7Bmain,geometry%7D.js Line 8

mgillesp commented 12 years ago

Sorry.. I was a little trigger happy on hitting "Enter".

I want to implement asynchronous actions on the Google Map now that it has been rendered, but I am afraid this error will cause problems.. Any thoughts?

Thanks for any input you have!

apneadiving commented 12 years ago

Hi,

you're welcome, visit this if you want to thank :)

Could you provide more details or give me some url to check this?

mgillesp commented 12 years ago

Ok,

So I am running rails 3.0.9, currently have the following code in my controller for the RESTful 'new' action.


    @map_options = { :type => "TERRAIN", :zoom => 6 }
    @google_ridemap = { :map_options => @map_options }

And the simple code within my view........


       gmaps( @google_ridemap ) 

When I look at firebug, I am getting the javascript error I listed previously. The map itself is loading wonderfully, and I also have other maps loading with directions as well. Could error be triggered by the fact that I am trying to use the Google Places Autocomplete as well? The following is defined within my 'head' tag


     script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&libraries=places"

Any suggestions??

apneadiving commented 12 years ago

the problem is that you load the maps api twice. The answer lies here: https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Map-Apis

You should pass all additional libraries to the gmaps helper to avoid loading it elsewhere.

mgillesp commented 12 years ago

Thanks for the help. Just a note for your other readers.....

Using the following did not work for me:


        gmaps({
          "map_options" => {"libraries" => ["places"] },
          ... #add here data you want to display
          })

However this did work........


        gmaps({
          "map_options" => { :libraries => ["places"] },
          ... #add here data you want to display
          })

I was looking at your gmaps helper source, and it has something to do with the code which appends ",places" to the end of the javascript url...

Maybe it is just my configuration of Rails, but I thought I would let you know.

Cheers.

apneadiving commented 12 years ago

right, I should correct that.

Thanks for reporting :)