mapbox / mapbox-sdk-rb

A Ruby interface to Mapbox APIs.
Other
59 stars 32 forks source link

Undefined method 'round' for nil:NilClass when running reverse geocoder example #27

Closed samfader closed 5 years ago

samfader commented 6 years ago

When I try to run the reverse geocoding example from the README:

placenames = Mapbox::Geocoder.geocode_reverse({
  "latitude" => 38,
  "longitude" => -100
})

I get the following error:

Traceback (most recent call last):
        3: from /usr/local/opt/ruby/bin/irb:11:in `<main>'
        2: from (irb):3
        1: from /Users/samfader/mapbox/mapbox-sdk-rb/lib/mapbox/geocoder.rb:47:in `geocode_reverse'
NoMethodError (undefined method `round' for nil:NilClass)
aehven commented 5 years ago

I find this works better with ':' instead of '=>' notation. So

Mapbox::Geocoder.geocode_reverse({"latitude" => 38, "longitude" => -100})

fails but

Mapbox::Geocoder.geocode_reverse({latitude: 38, longitude: -100})

succeeds whether you use symbols or strings for the attribute names.

When I try to run the reverse geocoding example from the README:

placenames = Mapbox::Geocoder.geocode_reverse({
  "latitude" => 38,
  "longitude" => -100
})

I get the following error:

Traceback (most recent call last):
        3: from /usr/local/opt/ruby/bin/irb:11:in `<main>'
        2: from (irb):3
        1: from /Users/samfader/mapbox/mapbox-sdk-rb/lib/mapbox/geocoder.rb:47:in `geocode_reverse'
NoMethodError (undefined method `round' for nil:NilClass)
samfader commented 5 years ago

Nice find, @aehven. I can look into this a bit more later.

samfader commented 5 years ago

Updated the README, should be good for now.

aehven commented 5 years ago

Updated the README, should be good for now.

Cool. Thanks!