Simplify creating a map location from a heading
This commit is contained in:
@@ -181,7 +181,7 @@ module Budgets
|
||||
end
|
||||
|
||||
def load_map
|
||||
@map_location = MapLocation.load_from_heading(@heading) if @heading.present?
|
||||
@map_location = MapLocation.from_heading(@heading) if @heading.present?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,11 +17,11 @@ class MapLocation < ApplicationRecord
|
||||
}
|
||||
end
|
||||
|
||||
def self.load_from_heading(heading)
|
||||
map = new
|
||||
map.zoom = Budget::Heading::OSM_DISTRICT_LEVEL_ZOOM
|
||||
map.latitude = heading.latitude.to_f if heading.latitude.present?
|
||||
map.longitude = heading.longitude.to_f if heading.longitude.present?
|
||||
map
|
||||
def self.from_heading(heading)
|
||||
new(
|
||||
zoom: Budget::Heading::OSM_DISTRICT_LEVEL_ZOOM,
|
||||
latitude: (heading.latitude.to_f if heading.latitude.present?),
|
||||
longitude: (heading.longitude.to_f if heading.longitude.present?)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user