diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e604adb021..1d3b3034f6 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -90,12 +90,12 @@ def insert_extras(body) end # we should move this to the Node model: - def render_map(lat, lon) - render partial: 'map/leaflet', locals: { lat: lat, lon: lon, top_map: false } + def render_map(lat, lon, zoom = '') + render partial: 'map/leaflet', locals: { lat: lat, lon: lon, zoom: zoom, top_map: false } end - def render_top_map(lat, lon) - render partial: 'map/leaflet', locals: { lat: lat, lon: lon, top_map: true } + def render_top_map(lat, lon, zoom = '') + render partial: 'map/leaflet', locals: { lat: lat, lon: lon, zoom: zoom, top_map: true } end # we should move this to the Comment model: diff --git a/app/views/map/_leaflet.html.erb b/app/views/map/_leaflet.html.erb index 5e0fc624fe..64bd42c06e 100644 --- a/app/views/map/_leaflet.html.erb +++ b/app/views/map/_leaflet.html.erb @@ -1,5 +1,6 @@ <%= render :partial => "map/mapDependencies" %> <% top_map = top_map || false %> +<% zoom = zoom || lat.to_s.length.to_i + 6 %> <% unique_id = rand(1000) %> <% if top_map == true %> @@ -21,23 +22,15 @@ var map<%= unique_id %> = L.map('top_map' , { maxBounds: bounds , maxBoundsViscosity: 0.75 - }).setView([<%= lat %>,<%= lon %>], <%= lat.to_s.length.to_i %> + 6); + }).setView([<%= lat %>,<%= lon %>], <%= zoom %>); <% else %> var map<%= unique_id %> = L.map('map<%= unique_id %>' , { maxBounds: bounds , maxBoundsViscosity: 0.75 - }).setView([<%= lat %>,<%= lon %>], <%= lat.to_s.length.to_i %> + 6); + }).setView([<%= lat %>,<%= lon %>], <%= zoom %>); <% end %> var markers_hash<%= unique_id %> = new Map() ; - var map_lat = <%= lat %> ; - var map_lon = <%= lon %> ; - - window.setTimeout(function(){ - - map<%= unique_id %>.setZoom(<%= lat.to_s.length.to_i %> + 6) ; - - }, 3500); setupLEL(map<%= unique_id %> , 0) ; diff --git a/app/views/sidebar/_related.html.erb b/app/views/sidebar/_related.html.erb index 64a522ebef..d9400e3a2c 100644 --- a/app/views/sidebar/_related.html.erb +++ b/app/views/sidebar/_related.html.erb @@ -42,9 +42,9 @@ <%= render partial: 'sidebar/notes', locals: { notes: @node.responses, title: I18n.t('sidebar._related.responses_to_note'), node: @node } %> <% end %> <% if @node && @node.has_tag("place") && @node.lat && @node.lon %> - <%= render_top_map(@node.lat, @node.lon) %> + <%= render_top_map(@node.lat, @node.lon, @node.zoom) %> <% elsif @node && @node.lat && @node.lon %> - <%= render_map(@node.lat, @node.lon) %> + <%= render_map(@node.lat, @node.lon, @node.zoom) %> <% elsif !@node.lat && !@node.lon %>