Module: Gmaps4rails::ActsAsGmappable::InstanceMethods

Included in:
ClassMethods
Defined in:
lib/acts_as_gmappable/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.gmaps4rails_trusted_scopesObject



161
162
163
# File 'lib/acts_as_gmappable/base.rb', line 161

def self.gmaps4rails_trusted_scopes
  []
end

Instance Method Details

#gmaps4rails_infowindowObject



124
125
# File 'lib/acts_as_gmappable/base.rb', line 124

def gmaps4rails_infowindow
end

#gmaps4rails_marker_pictureObject



153
154
155
156
157
158
159
# File 'lib/acts_as_gmappable/base.rb', line 153

def gmaps4rails_marker_picture
  {
    "picture" => "",
    "width" => "",
    "height" => ""
  }
end

#gmaps4rails_sidebarObject



130
131
# File 'lib/acts_as_gmappable/base.rb', line 130

def gmaps4rails_sidebar
end

#gmaps4rails_titleObject



127
128
# File 'lib/acts_as_gmappable/base.rb', line 127

def gmaps4rails_title
end

#process_geocodingObject



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/acts_as_gmappable/base.rb', line 133

def process_geocoding
  #to prevent geocoding each time a save is made
  return true if gmaps4rails_options[:check_process] == true && self[gmaps4rails_options[:checker]] == true
  
  begin
    coordinates = Gmaps4rails.geocode(self.gmaps4rails_address)
  rescue GeocodeStatus #adress was invalid, add error to base.
    errors[:base] << gmaps4rails_options[:msg] if gmaps4rails_options[:validation]
  rescue GeocodeNetStatus => e #connection error, No need to prevent save.
    logger.warn(e)
    #TODO add customization here?
  else #if no exception
    self[gmaps4rails_options[:lng_column]] = coordinates.first[:lng]
    self[gmaps4rails_options[:lat_column]] = coordinates.first[:lat]
    if gmaps4rails_options[:check_process] == true
      self[gmaps4rails_options[:checker]] = true
    end
  end
end

#to_gmaps4railsObject



165
166
167
168
169
# File 'lib/acts_as_gmappable/base.rb', line 165

def to_gmaps4rails
  json = "["
  json += Gmaps4rails.create_json(self).to_s.chop #removes the extra comma
  json += "]"
end