diff --git a/app/helpers/map_locations_helper.rb b/app/helpers/map_locations_helper.rb index e0350773c..8d295b1b6 100644 --- a/app/helpers/map_locations_helper.rb +++ b/app/helpers/map_locations_helper.rb @@ -32,21 +32,7 @@ module MapLocationsHelper map = content_tag_for :div, map_location, class: "map", - data:{ - map: "", - map_center_latitude: map_location_latitude(map_location), - map_center_longitude: map_location_longitude(map_location), - map_zoom: map_location_zoom(map_location), - map_tiles_attribution_selector: map_location_attribution_id(map_location), - map_tiles_provider: "//{s}.tile.osm.org/{z}/{x}/{y}.png", - marker_editable: editable, - marker_latitude: map_location.latitude, - marker_longitude: map_location.longitude, - marker_remove_selector: "##{map_location_remove_marker_link_id(map_location)}", - latitude_input_selector: "##{map_location_input_id(parent_class, 'latitude')}", - longitude_input_selector: "##{map_location_input_id(parent_class, 'longitude')}", - zoom_input_selector: "##{map_location_input_id(parent_class, 'zoom')}" - } + data: prepare_map_settings(map_location, editable, parent_class) map += map_attributtion(map_location) map += map_location_remove_marker(map_location, remove_marker_label) if editable map @@ -69,4 +55,24 @@ module MapLocationsHelper end end + private + + def prepare_map_settings(map_location, editable, parent_class) + options = { + map: "", + map_center_latitude: map_location_latitude(map_location), + map_center_longitude: map_location_longitude(map_location), + map_zoom: map_location_zoom(map_location), + map_tiles_attribution_selector: map_location_attribution_id(map_location), + map_tiles_provider: "//{s}.tile.osm.org/{z}/{x}/{y}.png", + marker_editable: editable, + marker_latitude: map_location.latitude, + marker_longitude: map_location.longitude, + marker_remove_selector: "##{map_location_remove_marker_link_id(map_location)}", + latitude_input_selector: "##{map_location_input_id(parent_class, 'latitude')}", + longitude_input_selector: "##{map_location_input_id(parent_class, 'longitude')}", + zoom_input_selector: "##{map_location_input_id(parent_class, 'zoom')}" + } + end + end \ No newline at end of file diff --git a/app/views/map_locations/_form_fields.html.erb b/app/views/map_locations/_form_fields.html.erb index f838d1f98..95e0331ae 100644 --- a/app/views/map_locations/_form_fields.html.erb +++ b/app/views/map_locations/_form_fields.html.erb @@ -1,7 +1,7 @@ <%= form.label :map_location, label %>

<%= help %>

-<%= render_map(map_location, parent_class, true, remove_marker_label) %> +<%= render_map(map_location, parent_class, editable = true, remove_marker_label) %> <%= form.fields_for :map_location, map_location do |m_l_fields| %> <%= m_l_fields.hidden_field :latitude,