Skip to content
Permalink
Browse files

worldmap - consistent page reloads

  • Loading branch information...
vpithart authored and LarsMichelsen committed Jul 9, 2019
1 parent 8a16d01 commit 75d310e33ac5d523d05970bce0d42ff9e173f402
Showing with 20 additions and 3 deletions.
  1. +3 −0 ChangeLog
  2. +17 −3 share/frontend/nagvis-js/js/ViewWorldmap.js
@@ -3,6 +3,9 @@ Core:
* MKBI backend: Use "htmlcgi" URL/path for building links to the Checkmk GUI
(Aggregations used the base_url, which should not be used for user URLs)

Worldmap:
* Consistent page reloads: center + zoom of the map kept in URL

Frontend
* FIX: Fix creating users when mbstring extension is not available

@@ -70,14 +70,24 @@ var ViewWorldmap = ViewMap.extend({
detectRetina: true, // look nice on high resolution screens
maxZoom: 20,
})
}
}

g_map = L.map('map', {
markerZoomAnimation: false,
maxBounds: [ [-85,-180.0], [85,180.0] ],
minZoom: 2,
layers: [layers.map]
}).setView(getViewParam('worldmap_center').split(','), parseInt(getViewParam('worldmap_zoom')));

})

let restored_coordinates = window.location.hash.substr(1).split('/');
if (restored_coordinates.length === 3) {
// place the map view according to location hash (#lat/lon/zoom) - consistent page reloads
g_map.setView([restored_coordinates[1], restored_coordinates[0]], restored_coordinates[2]);
} else {
// or default (map-defined) view
g_map.setView(getViewParam('worldmap_center').split(','), parseInt(getViewParam('worldmap_zoom')));
}

if (layers.satellite)
L.control.layers(layers).addTo(g_map);

@@ -115,6 +125,10 @@ var ViewWorldmap = ViewMap.extend({
setViewParam('worldmap_zoom', g_map.getZoom());

this.render(); // re-render the whole map

// Put the new map view coords into URL (location) - consistent reloads
new_center = g_map.getCenter();
window.location.hash = `${new_center.lng}/${new_center.lat}/${g_map.getZoom()}`;
},

saveView: function() {

0 comments on commit 75d310e

Please sign in to comment.
You can’t perform that action at this time.