I want to create a dynamic map using Ruby on Rails, geojson, gem rgeo-geojson, and mapbox.js.
I have a form where users input a country with a select generated by a JSON file listing all the countries.
I want Rails to compare it with a countries.geo.json
file listing all countries, and then generate a marker on the map with the country selected.
Here is my application_helper.rb where I create the select option form :
def countries_for_select
file = File.read(Rails.root.join( 'app', 'helpers', 'countries.json'))
countries = JSON.parse(file)
countries.map {|c| [c['name']] }
end
using countries.json file, and now I want to generate a marker on the map (mapbox) depending on which country user choose
My countries.json file is like that :
[
{
"name": "Afghanistan",
"code": "AF"
},
{
"name": "Åland Islands",
"code": "AX"
},