Create constants for default map location
This commit is contained in:
parent
442a6a3cdd
commit
ee3ff78b12
2 changed files with 9 additions and 5 deletions
|
@ -1,4 +1,8 @@
|
||||||
class Champs::CarteChamp < Champ
|
class Champs::CarteChamp < Champ
|
||||||
|
# Default map location. Center of the World, ahm, France...
|
||||||
|
DEFAULT_LON = 2.428462
|
||||||
|
DEFAULT_LAT = 46.538192
|
||||||
|
|
||||||
# We are not using scopes here as we want to access
|
# We are not using scopes here as we want to access
|
||||||
# the following collections on unsaved records.
|
# the following collections on unsaved records.
|
||||||
def cadastres
|
def cadastres
|
||||||
|
@ -41,8 +45,8 @@ class Champs::CarteChamp < Champ
|
||||||
if dossier.present?
|
if dossier.present?
|
||||||
dossier.geo_position
|
dossier.geo_position
|
||||||
else
|
else
|
||||||
lon = "2.428462"
|
lon = DEFAULT_LON.to_s
|
||||||
lat = "46.538192"
|
lat = DEFAULT_LAT.to_s
|
||||||
zoom = "13"
|
zoom = "13"
|
||||||
|
|
||||||
{ lon: lon, lat: lat, zoom: zoom }
|
{ lon: lon, lat: lat, zoom: zoom }
|
||||||
|
@ -61,7 +65,7 @@ class Champs::CarteChamp < Champ
|
||||||
point = dossier.geo_position
|
point = dossier.geo_position
|
||||||
bounding_box.add(factory.point(point[:lon], point[:lat]))
|
bounding_box.add(factory.point(point[:lon], point[:lat]))
|
||||||
else
|
else
|
||||||
bounding_box.add(factory.point(2.428462, 46.538192))
|
bounding_box.add(factory.point(DEFAULT_LON, DEFAULT_LAT))
|
||||||
end
|
end
|
||||||
|
|
||||||
[bounding_box.max_point, bounding_box.min_point].compact.flat_map(&:coordinates)
|
[bounding_box.max_point, bounding_box.min_point].compact.flat_map(&:coordinates)
|
||||||
|
|
|
@ -425,8 +425,8 @@ class Dossier < ApplicationRecord
|
||||||
point = Geocoder.search(etablissement.geo_adresse).first
|
point = Geocoder.search(etablissement.geo_adresse).first
|
||||||
end
|
end
|
||||||
|
|
||||||
lon = "2.428462"
|
lon = Champs::CarteChamp::DEFAULT_LON.to_s
|
||||||
lat = "46.538192"
|
lat = Champs::CarteChamp::DEFAULT_LAT.to_s
|
||||||
zoom = "13"
|
zoom = "13"
|
||||||
|
|
||||||
if point.present?
|
if point.present?
|
||||||
|
|
Loading…
Add table
Reference in a new issue