geojson is now all generated from views
This commit is contained in:
parent
b1ce7a0ec9
commit
1df5c3f9b7
@ -19,7 +19,7 @@ class MapsController < ApplicationController
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json do
|
||||
render json: apply_scopes(Orga.moderated.active.geo).where(kind: @kind)
|
||||
@orgas = apply_scopes(Orga.moderated.active.geo).where kind: @kind
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -81,15 +81,6 @@ class Orga < ApplicationRecord
|
||||
name.gsub(/\AL'/, '').gsub(/[\s\*'\.]/, '-').delete ':'
|
||||
end
|
||||
|
||||
def as_json(_options = {})
|
||||
{ type: 'Feature', properties: {
|
||||
id: id, icon: kind.icon, name: name,
|
||||
place_name: place_name, address: address, city: city,
|
||||
tags: tags,
|
||||
popupContent: "<a href=\"/orgas/#{id}\">#{self}</a>"
|
||||
}, geometry: { type: 'Point', coordinates: [longitude, latitude] } }
|
||||
end
|
||||
|
||||
def full_address
|
||||
[address, city, region, region.try(:region)].compact.join ', '
|
||||
end
|
||||
|
@ -10,7 +10,7 @@ json.array!(@events) do |event|
|
||||
place_name: event.place_name, address: event.address, city: event.city,
|
||||
region: event.region.name, region_id: event.region_id,
|
||||
tags: event.tag_list,
|
||||
popupContent: link_to(event, event)
|
||||
popupContent: link_to(event, event_url(event))
|
||||
},
|
||||
geometry: {
|
||||
type: 'Point',
|
||||
|
18
app/views/maps/show.json.jbuilder
Normal file
18
app/views/maps/show.json.jbuilder
Normal file
@ -0,0 +1,18 @@
|
||||
json.array!(@orgas) do |orga|
|
||||
json.merge!(
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
id: orga.id,
|
||||
icon: @kind.icon,
|
||||
name: orga.name,
|
||||
place_name: orga.place_name, address: orga.address, city: orga.city,
|
||||
region: orga.region.name, region_id: orga.region_id,
|
||||
tags: orga.tag_list,
|
||||
popupContent: link_to(orga, orga_url(orga))
|
||||
},
|
||||
geometry: {
|
||||
type: 'Point',
|
||||
coordinates: [orga.longitude, orga.latitude]
|
||||
}
|
||||
)
|
||||
end
|
Loading…
Reference in New Issue
Block a user