Closed dthyresson closed 6 years ago
The README example:
# Reverse geocoding placenames = Mapbox::Geocoder.geocode_reverse({ "latitude" => 38, "longitude" => -100 })
fails
NoMethodError: undefined methodround' for nil:NilClass`
NoMethodError: undefined method
because https://github.com/mapbox/mapbox-sdk-rb/blob/master/lib/mapbox/geocoder.rb#L21 expects symbolic keys as in:
placenames = Mapbox::Geocoder.geocode_reverse({ latitude: 38, longitude: -100 })
which returns
[ { "attribution": "NOTICE: © 2016 Mapbox and its suppliers. All rights reserved. Use of this data is subject to the Mapbox Terms of Service (https://www.mapbox.com/about/maps/). This response and the information it contains may not be retained.", "features": [ { "center": [ -100.000007176662, 38.000312209294201 ], "context": [ { "id": "place.9991796195976750", "text": "Jetmore",
You want to do something like this:
JSON.parse(location, symbolize_names: true)
edit:
That being said it could be useful if the geocoder accepted an array of [lat,lng] or a hash with indifferent access.
[lat,lng]
The README example:
fails
NoMethodError: undefined method
round' for nil:NilClass`because https://github.com/mapbox/mapbox-sdk-rb/blob/master/lib/mapbox/geocoder.rb#L21 expects symbolic keys as in:
which returns