aboutsummaryrefslogtreecommitdiff
path: root/app/helpers/leaflet_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/leaflet_helper.rb')
-rw-r--r--app/helpers/leaflet_helper.rb19
1 files changed, 15 insertions, 4 deletions
diff --git a/app/helpers/leaflet_helper.rb b/app/helpers/leaflet_helper.rb
index 6ca03f3..67820d3 100644
--- a/app/helpers/leaflet_helper.rb
+++ b/app/helpers/leaflet_helper.rb
@@ -1,11 +1,22 @@
module LeafletHelper
- def marker_for(resource, options = {})
- coords = [resource.latitude, resource.longitude]
+ def json_marker_for(resource, section)
+ # Style according to requested section
+ marker = resource.to_geojson
+ marker['style'] = {
+ classes: "cat#{section.category_id} sec#{section.id}",
+ color: section.category.color
+ }
+ marker['icon'] = {
+ name: 'fa-neuter' || section.icon_name || 'fa-circle',
+ shape: 'penta' # TODO: change shape according to marker state
+ }
+ # Render HTML popup
+ marker['popup'] = popup_for(resource)
- "L.marker(#{coords}, #{options}).bindPopup(%s)" % popup_for(resource)
+ marker.to_json
end
def popup_for(resource)
- render partial: 'resource/popup', locals: { resource: resource }
+ render partial: 'resources/popup', locals: { resource: resource }, formats: [:html]
end
end