From: Tom Hughes Date: Tue, 3 Dec 2013 14:53:24 +0000 (+0000) Subject: Improve zoom level selection when invoking Potlatch on an object X-Git-Tag: live~5186 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/50fafa14f86a9ff02458c1e055f24c199f14a8eb Improve zoom level selection when invoking Potlatch on an object When invoking Potlatch on a node/way/relation object we should normally have valid location information in the map parameters, so use any zoom which is there if possible, otherwise fall back to an object type specific default value. Fixes #605. --- diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 5c391d7b2..1f33b067b 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -50,18 +50,22 @@ class SiteController < ApplicationController bbox = Node.find(params[:node]).bbox.to_unscaled @lat = bbox.centre_lat @lon = bbox.centre_lon + @zoom = 18 elsif params[:way] bbox = Way.find(params[:way]).bbox.to_unscaled @lat = bbox.centre_lat @lon = bbox.centre_lon + @zoom = 17 elsif params[:note] note = Note.find(params[:note]) @lat = note.lat @lon = note.lon + @zoom = 17 elsif params[:gpx] trace = Trace.visible_to(@user).find(params[:gpx]) @lat = trace.latitude @lon = trace.longitude + @zoom = 16 end end diff --git a/app/views/site/_potlatch.html.erb b/app/views/site/_potlatch.html.erb index 32dc99e8e..b82a82944 100644 --- a/app/views/site/_potlatch.html.erb +++ b/app/views/site/_potlatch.html.erb @@ -51,11 +51,11 @@ // 700,600 for fixed size, 100%,100% for resizable } + var mapParams = OSM.mapParams(); <% if @lat && @lon -%> - doSWF(<%= @lat %>,<%= @lon %>,16); + doSWF(<%= @lat %>, <%= @lon %>, mapParams.zoom || <%= @zoom %>); <% else -%> - var params = OSM.mapParams(); - doSWF(params.lat, params.lon, params.zoom || 17); + doSWF(mapParams.lat, mapParams.lon, mapParams.zoom || 17); <% end -%> $(document).ready(function () { diff --git a/app/views/site/_potlatch2.html.erb b/app/views/site/_potlatch2.html.erb index 2f8e10a5b..bb811d652 100644 --- a/app/views/site/_potlatch2.html.erb +++ b/app/views/site/_potlatch2.html.erb @@ -70,11 +70,11 @@ } } + var mapParams = OSM.mapParams(); <% if @lat && @lon -%> - doSWF(<%= @lat %>,<%= @lon %>,16); + doSWF(<%= @lat %>, <%= @lon %>, mapParams.zoom || <%= @zoom %>); <% else -%> - var params = OSM.mapParams(); - doSWF(params.lat, params.lon, params.zoom || 17); + doSWF(mapParams.lat, mapParams.lon, mapParams.zoom || 17); <% end -%> $("body").on("click", "a.set_position", function (e) {