Class: Administrate::Field::LatLng

Inherits:
Base
  • Object
show all
Defined in:
lib/administrate/field/lat_lng.rb

Defined Under Namespace

Classes: Engine

Instance Method Summary collapse

Instance Method Details

#google_api_keyObject



40
41
42
# File 'lib/administrate/field/lat_lng.rb', line 40

def google_api_key
  options.fetch(:google_api_key, nil)
end

#initialObject

Returns the initial co-ordinates of blank maps (defaults to Leeds, UK)



50
51
52
# File 'lib/administrate/field/lat_lng.rb', line 50

def initial
  options.fetch(:initial, [53.8003,-1.5519])
end

#lat?Boolean

True if the :lat option has been provided, or field is called :lat

Returns:

  • (Boolean)


25
26
27
# File 'lib/administrate/field/lat_lng.rb', line 25

def lat?
  options.fetch(:lat, attribute == :lat)
end

#lng?Boolean

True if the :lng option has been provided, or field is called :lng

Returns:

  • (Boolean)


30
31
32
# File 'lib/administrate/field/lat_lng.rb', line 30

def lng?
  options.fetch(:lng, attribute == :lng)
end

#search?Boolean

Return wether or not search should be enabled (defaults to true)

Returns:

  • (Boolean)


35
36
37
# File 'lib/administrate/field/lat_lng.rb', line 35

def search?
  options.fetch(:search, true) && google_api_key.present?
end

#to_sObject



59
60
61
# File 'lib/administrate/field/lat_lng.rb', line 59

def to_s
  data
end

#whichObject

Returns :lat or :lng depending on which type this is



45
46
47
# File 'lib/administrate/field/lat_lng.rb', line 45

def which
  lat? ? :lat : :lng
end

#zoomObject

Returns the initial zoom level for maps (defaults to 11)



55
56
57
# File 'lib/administrate/field/lat_lng.rb', line 55

def zoom
  options.fetch(:zoom, 11)
end