1

位置已添加到表中。但缺少纬度/经度。所以没有标记添加到地图上。

class Location < ActiveRecord::Base
  validates :priority,:addr,:presence=>true
  validates :priority,:numericality=>{:greater_than_or_equal_to =>1,:less_than_or_equal_to =>6}
  default_scope :order=>'priority'
  acts_as_gmappable :lat=>'lat',:lng=>'lng'

  def gmaps4rails_address
    self.addr
  end

  def gmaps4rails_infowindow
    "<h4>Target priority: #{priority}</h4>" << "<h4>Address: #{addr}</h4>" << "<h4>Latitude: #{lat}</h4>" << "<h4>Longitude: #{lng}</h4>"
  end

 def gmaps4rails_marker_picture
  {
      "picture" => "/images/#{priority%7}.jpg",
      "width" => "30",
      "height" => "30"
  }
  end
end

添加新位置后

4

1 回答 1

0

只需设置gmapsfalse触发地理编码(如文档所述)

于 2012-05-02T12:32:02.587 回答