Module: OnTheMap::GeoLocatable

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

Instance Method Summary collapse

Instance Method Details

#geocodable?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/on_the_map/geo_locatable.rb', line 69

def geocodable?
  !position && geolocatable? || address.changed?
end

#geocoding?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/on_the_map/geo_locatable.rb', line 82

def geocoding?
  @geocoding_started == true
end

#geolocatable?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/on_the_map/geo_locatable.rb', line 73

def geolocatable?
  address && address.geolocatable?
end

#latitudeObject Also known as: lat



57
58
59
60
# File 'lib/on_the_map/geo_locatable.rb', line 57

def latitude
  perform_geocoding unless position
  position[1].to_i if position
end

#longitudeObject Also known as: lng



63
64
65
66
# File 'lib/on_the_map/geo_locatable.rb', line 63

def longitude
  perform_geocoding unless position
  position[0].to_i if position
end

#perform_geocodingObject Also known as: perform_geocoding!



77
78
79
# File 'lib/on_the_map/geo_locatable.rb', line 77

def perform_geocoding
  geocode if geocodable? && !geocoding?
end