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

Getting an empty map div with class gmaps4rails_map #257

Closed tetherit closed 12 years ago

tetherit commented 12 years ago

This is my model:

class Scope
  include Mongoid::Document
  include Geocoder::Model::Mongoid
  validates_presence_of :name, :address
  after_validation :geocode, :if => :address_changed?
  geocoded_by :address
  acts_as_gmappable :position => :coordinates

  field :name
  field :address
  field :coordinates, type: Array
end

This is in my controller:

  def show
    @scope = Scope.find(params[:id])
    @json = @scope.to_gmaps4rails

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @scope }
    end
  end

This is in my view:

= gmaps4rails(@json)

The contents of the @json are:

[{"lat":0.2192366,"lng":51.6036666}]

Looking at the HTML source, I just see:

<div class="map_container"> 
    <div id="map" class="gmaps4rails_map"></div>
 </div>

Any ideas?

tetherit commented 12 years ago

Sorry, was missing the = yield :scripts in my layouts file!