From 1673851b50e2932f04891c8140af58464c2866c4 Mon Sep 17 00:00:00 2001 From: Aaron Lidman Date: Tue, 12 Nov 2013 15:12:32 -0800 Subject: [PATCH] Add zoom to note --- app/assets/javascripts/index.js | 2 +- app/assets/javascripts/index/note.js.erb | 12 ++++++++++-- app/views/browse/note.html.erb | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index e0ca66766..15b45d31c 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -204,7 +204,7 @@ $(document).ready(function () { page.load = function(path, type, id) { if (OSM.STATUS === 'api_offline' || OSM.STATUS === 'database_offline') return; - map.addObject({type: type, id: parseInt(id)}, {zoom: true}); + map.addObject({type: type, id: parseInt(id)}, {zoom: window.location.hash == ""}); }; page.unload = function() { diff --git a/app/assets/javascripts/index/note.js.erb b/app/assets/javascripts/index/note.js.erb index a11f6a72c..9afe3b5f8 100644 --- a/app/assets/javascripts/index/note.js.erb +++ b/app/assets/javascripts/index/note.js.erb @@ -1,7 +1,8 @@ OSM.Note = function(map) { var noteLayer = map.noteLayer, content = $('#sidebar_content'), - page = {}; + page = {}, + marker; var noteIcons = { "new": L.icon({ @@ -67,7 +68,7 @@ OSM.Note = function(map) { page.load(); }; - page.load = function() { + page.load = function(path, id) { var loadTimer = setTimeout(setLoading, 250); $('#sidebar_content').load(window.location.pathname + "?xhr=1", function(a, b, xhr) { if (xhr.getResponseHeader('X-Page-Title')) { @@ -76,9 +77,16 @@ OSM.Note = function(map) { bind(); clearTimeout(loadTimer); clearLoading(); + + if (!map.hasLayer(noteLayer)) map.addLayer(noteLayer); + if (window.location.hash == "") map.panTo($('.details').data().coordinates.split(',')); }); }; + page.unload = function() { + if (marker) map.removeLayer(marker); + }; + function setLoading() { if($('#browse_status').is(':empty')) { $('#browse_status').append($('

').text(I18n.t('browse.start_rjs.loading'))); diff --git a/app/views/browse/note.html.erb b/app/views/browse/note.html.erb index f6db9f154..a377ada6a 100644 --- a/app/views/browse/note.html.erb +++ b/app/views/browse/note.html.erb @@ -6,7 +6,7 @@
-
+
<%= t "browse.note.#{@note.status}_title", :note_name => @note.id %>
<%= note_event('open', @note.created_at, @note.author) %> -- 2.43.2