位置已添加到表中。但缺少纬度/经度。所以没有标记添加到地图上。
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