agenda-libre-ruby/app/controllers/maps_controller.rb

26 lines
696 B
Ruby

class MapsController < ApplicationController
def index
respond_to do |format|
format.html
format.json {
events = Event.moderated.future.joins(:related_city).includes(:related_city)
#@cities_lug = City.joins :lugs
render json: events.collect { |event|
{
type: 'Feature',
properties: {
name: event.title,
popupContent: "<a href=\"#{event_url event}\">#{event.city}: #{event.title}</a>",
}, geometry: {
type: 'Point',
coordinates: [event.related_city.longitude, event.related_city.latitude]
}
}
}
}
end
end
end