Skip to content
Snippets Groups Projects
Commit a35a1ca6 authored by Alex Reisner's avatar Alex Reisner
Browse files

Don't do lookup if parameters blank.

parent 70cc64ee
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ module Geocoder
# Returns array [lat,lon] if found, nil if not found or if network error.
#
def coordinates(address)
return nil if address.blank?
return nil unless doc = search(address, false)
# blindly use first result (assume it is most accurate)
place = doc['results'].first['geometry']['location']
......@@ -18,6 +19,7 @@ module Geocoder
# Returns string if found, nil if not found or if network error.
#
def address(latitude, longitude)
return nil if latitude.blank? || longitude.blank?
return nil unless doc = search("#{latitude},#{longitude}", true)
# blindly use first result (assume it is most accurate)
doc['results'].first['formatted_address']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment