简体   繁体   中英

TypeError: no implicit conversion of Symbol into Integer for search with geokit-rails

I've got the geokit-rails gem installed with geocoder, and have loaded my configuration correctly with the right API keys and settings. I've properly constructed ActiveRecord objects that have encoded lat and lng columns with float values. Now I am trying to simply search for venues (Venue activerecord) that are within 100km of the given origin as so:

Venue.within(100, origin: Geokit::LatLng.new(-27.12,124.2141))

Yet I keep receiving the error:

TypeError: no implicit conversion of Symbol into Integer
    from /usr/local/lib/ruby/gems/2.1.0/gems/geocoder-1.2.3/lib/geocoder/sql.rb:14:in `[]'
    from /usr/local/lib/ruby/gems/2.1.0/gems/geocoder-1.2.3/lib/geocoder/sql.rb:14:in `full_distance'
    from /usr/local/lib/ruby/gems/2.1.0/gems/geocoder-1.2.3/lib/geocoder/stores/active_record.rb:157:in `distance_sql'
    from /usr/local/lib/ruby/gems/2.1.0/gems/geokit-rails-2.0.1/lib/geokit-rails/acts_as_mappable.rb:228:in `distance_conditions'
    from /usr/local/lib/ruby/gems/2.1.0/gems/geokit-rails-2.0.1/lib/geokit-rails/acts_as_mappable.rb:108:in `within'
    from (irb):46
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.0/lib/rails/commands/console.rb:90:in `start'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.0/lib/rails/commands/console.rb:9:in `start'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:69:in `console'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.0/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Would someone help?

You could use Geokit within method with Lat&Long directly - from docs . Fe: :origin => [37.792,-122.393]. In your case Venue.within(100, origin: [-27.12,124.2141])

Why do you use Geokit::LatLng.new for this?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM