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