});
}
- var marker = L.marker([0, 0], {icon: getUserIcon()});
-
- if (!params.object_zoom) {
- if (params.bounds) {
- map.fitBounds(params.bounds);
- } else {
- map.setView([params.lat, params.lon], params.zoom);
- }
+ if (params.bounds) {
+ map.fitBounds(params.bounds);
+ } else {
+ map.setView([params.lat, params.lon], params.zoom);
}
+ var marker = L.marker([0, 0], {icon: getUserIcon()});
+
if (params.marker) {
marker.setLatLng([params.mlat, params.mlon]).addTo(map);
}
});
}
- initializeBrowse(map, params);
- initializeNotes(map, params);
+ initializeBrowse(map);
+ initializeNotes(map);
OSM.Index = function(map) {
var page = {};
OSM.Browse = function(map) {
var page = {};
- page.pushstate = page.popstate = function(path) {
- $('#sidebar_content').load(path, page.load);
+ page.pushstate = page.popstate = function(path, type, id) {
+ $('#sidebar_content').load(path, function() {
+ page.load(path, type, id);
+ });
};
- page.load = function() {
- map.addObject(OSM.mapParams().object, {zoom: true});
+ page.load = function(path, type, id) {
+ if (OSM.STATUS === 'api_offline' || OSM.STATUS === 'database_offline') return;
+
+ if (type === 'note') {
+ map.noteLayer.showNote(parseInt(id));
+ } else {
+ map.addObject({type: type, id: parseInt(id)}, {zoom: true});
+ }
};
page.unload = function() {
//= require templates/notes/show
//= require templates/notes/new
-function initializeNotes(map, params) {
+function initializeNotes(map) {
var noteLayer = map.noteLayer,
notes = {},
newNote;
}
});
- if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') {
- if (params.note) {
- $.ajax({
- url: "/api/" + OSM.API_VERSION + "/notes/" + params.note + ".json",
- success: function (feature) {
- var marker = updateMarker(notes[feature.properties.id], feature);
- notes[feature.properties.id] = marker;
- map.addLayer(noteLayer);
- marker.openPopup();
- }
- });
- }
- }
+ noteLayer.showNote = function(id) {
+ $.ajax({
+ url: "/api/" + OSM.API_VERSION + "/notes/" + id + ".json",
+ success: function (feature) {
+ var marker = updateMarker(notes[feature.properties.id], feature);
+ notes[feature.properties.id] = marker;
+ map.addLayer(noteLayer);
+ marker.openPopup();
+ }
+ });
+ };
function updateMarker(marker, feature) {
if (marker) {
mapParams.mlat = parseFloat(params.mlat);
}
- match = window.location.pathname.match(/\/browse\/(node|way|relation|changeset)\/(\d+)/);
- if (match) {
- mapParams.object_zoom = true;
- mapParams.object = {type: match[1], id: parseInt(match[2])};
- } else if (params.node || params.way || params.relation || params.note) {
- mapParams.object_zoom = true;
-
- if (params.node) {
- mapParams.object = {type: 'node', id: parseInt(params.node)};
- } else if (params.way) {
- mapParams.object = {type: 'way', id: parseInt(params.way)};
- } else if (params.relation) {
- mapParams.object = {type: 'relation', id: parseInt(params.relation)};
- }
- }
-
- match = window.location.pathname.match(/\/browse\/note\/(\d+)/);
- if (match) {
- mapParams.note = parseInt(match[1]);
- } else if (params.note) {
- mapParams.note = parseInt(params.note);
+ if (params.node) {
+ mapParams.object = {type: 'node', id: parseInt(params.node)};
+ } else if (params.way) {
+ mapParams.object = {type: 'way', id: parseInt(params.way)};
+ } else if (params.relation) {
+ mapParams.object = {type: 'relation', id: parseInt(params.relation)};
}
var hash = OSM.parseHash(location.hash);
mapParams.lon = hash.center.lng;
mapParams.lat = hash.center.lat;
mapParams.zoom = hash.zoom;
- mapParams.object_zoom = false;
} else if (params.lon && params.lat) {
mapParams.lon = parseFloat(params.lon);
mapParams.lat = parseFloat(params.lat);
mapParams.zoom = parseInt(params.zoom || 5);
- mapParams.object_zoom = false;
} else if (params.mlon && params.mlat) {
mapParams.lon = parseFloat(params.mlon);
mapParams.lat = parseFloat(params.mlat);
mapParams.zoom = parseInt(params.zoom || 12);
- mapParams.object_zoom = false;
} else if (loc = $.cookie('_osm_location')) {
loc = loc.split("|");
mapParams.lon = parseFloat(loc[0]);
<div class="note">
- <a class="icon link permalink deemphasize" href="/?note=<%- note.id %>"><span><%- I18n.t('javascripts.notes.show.permalink', { id: note.id }) %></span></a>
+ <a class="icon link permalink deemphasize" href="/browse/note/<%- note.id %>"><span><%- I18n.t('javascripts.notes.show.permalink', { id: note.id }) %></span></a>
<% if (note.comments.some(function (comment) { return !comment.user })) { %>
<small class="warning"><%- I18n.t('javascripts.notes.show.anonymous_warning') %></small>
<% } %>