From b6aeac4d9274f17e748efb3715aa08f4b7c361f2 Mon Sep 17 00:00:00 2001 From: hellekin Date: Wed, 11 Nov 2020 22:27:18 +0100 Subject: Add map support This commit creates a dedicated Map model and moves the JavaScript from view to a Stimulus controller. - Stimulus.js https://stimulusjs.org - Leaflet.js https://leafletjs.org Upcoming resources: - https://discourse.stimulusjs.org/t/leafletjs-with-stimulusjs-on-rails-6/1343/4 - https://github.com/ghybs/leaflet-defaulticon-compatibility --- app/helpers/application_helper.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/helpers') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0b22f4b..aa3a8d7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -7,4 +7,18 @@ module ApplicationHelper current_agency.send(:"#{role}?") end end + + def map_container(map = Map.first) + raw tag.div( + tag.div(id: 'map', + data: { + target: 'map.container' + }), + data: { + controller: 'map', + 'map-latitude': map.latitude, + 'map-longitude': map.longitude, + 'map-zoom': map.zoom + }) + end end -- cgit v1.2.3