Module: OnTheMap::Mappable

Extended by:
ActiveSupport::Concern
Defined in:
lib/on_the_map/mappable.rb

Instance Method Summary collapse

Instance Method Details

#gmaps4rails_addressObject

describe how to retrieve the address from your model, if you use directly a db column, you can dry your code, see wiki



42
43
44
45
# File 'lib/on_the_map/mappable.rb', line 42

def gmaps4rails_address
  return address_str if respond_to? :address_str # Use GeoLocatable if such exists
  "#{address.street}, #{address.city}, #{address.country}" 
end

#gmaps_geocode?Boolean

When Geo Coding is to be performed by Gmaps4rails Leave it up to geocoder!

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/on_the_map/mappable.rb', line 24

def gmaps_geocode?
  # has_address? && (has_position? || has_geo_coords?) && 
  false # (!address.blank? && (lat.blank? || lng.blank?)) || position_changed?      
end

#has_address?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/on_the_map/mappable.rb', line 37

def has_address?
  respond_to?(:address) && address
end

#has_geo_coords?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/on_the_map/mappable.rb', line 29

def has_geo_coords?
  respond_to?(:latitude) && latitude && respond_to?(:longitude) && longitude
end

#has_position?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/on_the_map/mappable.rb', line 33

def has_position?
  respond_to?(:position) && position
end