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

div displays but map doesn't #153

Closed JulianMiller closed 12 years ago

JulianMiller commented 12 years ago

I think I've followed all of the docs but I can't seem to get the map to display even though the div does. I'm running Rails 3.2.1

I added @json = Location.all.to_gmaps4rails to my LocationsController

locations.rb has:

class Location < ActiveRecord::Base attr_accessible :latitude, :longitude, :name, :address, :phone, :blurb acts_as_gmappable

def gmaps4rails "#{self.longitude}, #{self.latitude}" end end

added <%= gmaps4rails(@json) %> to my view

and added <%= yield :scripts %> to my footer. anyone else having this issue?

apneadiving commented 12 years ago

I guess you found the solution :)

shaunbrazier commented 12 years ago

Hi,

What was the solution? I'm following the instructions on GitHub, all JS and CSS files appear to be loaded from the asset pipeline but only an empty div displays. I see no JS error in the firebug console and testing (rake assets:precompile --trace just in case it is a pipeline issue) completes without issue.

Everything else with the gem is working (saving down lat/lon and returning JSON etc) - just displaying in the view that appears to be missing something.

Do you need a Gmaps API key or something to display a Gmap? I'm currently trying to view it on localhost:3000.

Any ideas?

shaunbrazier commented 12 years ago

Sorry - ignore that last comment. I had failed to realise that the <%= yield :scripts %> was required as well as requiring:

//= require gmaps4rails/gmaps4rails.base //= require gmaps4rails/gmaps4rails.googlemaps

in my JS manifest file. After doing that, all seems to work. However, I have put all Gmap scripts at the end of the my HTML, after all other scripts, including Google Analytic scripts - there may have been some conflict there too.

apneadiving commented 12 years ago

Conflicts? What error? What error msg?

Sent from my iPhone

On 27 août 2012, at 06:39, shaunbrazier notifications@github.com wrote:

Sorry - ignore that last comment. I had failed to realise that the <%= yield :scripts %> was required as well as requiring:

//= require gmaps4rails/gmaps4rails.base //= require gmaps4rails/gmaps4rails.googlemaps

in my JS manifest file. After doing that, all seems to work. However, I have put all Gmap scripts at the end of the my HTML, after all other scripts, including Google Analytic scripts - there may have been some conflict there too.

— Reply to this email directly or view it on GitHub.