Fix pan then lock, unlock then pan. And mouse coordinates at start

to close #81  and close #82
This commit is contained in:
Dave Conway-Jones 2019-03-14 23:30:07 +00:00
parent baeb62427e
commit 8447c768b9
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
4 changed files with 63 additions and 58 deletions

View File

@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap
- v1.5.31 - Fix pan first at start, and coords overlay. Issues #81 and #82
- v1.5.30 - Add tooltip option, ability to remove base layer, search on icon, show mouse pointer co-ordinates
- v1.5.29 - remove lat/lon from popup if using .popup property. Allow icon to be loaded from http.
- v1.5.28 - Tidy up popup location and timing. Auto add countries overlay if no internet.

View File

@ -9,6 +9,7 @@ map web page for plotting "things" on.
### Updates
- v1.5.31 - Fix pan first at start, and coords overlay. Issues #81 and #82
- v1.5.30 - Add .tooltip option, ability to remove base layer, search on icon, show mouse pointer co-ordinates
- v1.5.29 - Remove lat/lon from popup if using .popup property. Allow icon to be loaded from http.
- v1.5.28 - Tidy up popup location and timing. Auto add countries overlay if no internet.

View File

@ -133,7 +133,6 @@ var clusterAt = 13;
var maxage = 600; // default max age of icons on map in seconds - cleared after 10 mins
var baselayername = "OSM grey"; // Default base layer OSM but uniform grey
var ibmfoot = " © IBM 2015,2019"
var initialposition = false;
var inIframe = false;
var showUserMenu = true;
var showLayerMenu = true;
@ -221,21 +220,22 @@ document.addEventListener ("keydown", function (ev) {
}
});
if ( window.localStorage.hasOwnProperty("lastpos") ) {
initialposition = true;
var sp = JSON.parse(window.localStorage.getItem("lastpos"));
startpos = [ sp.lat, sp.lng ];
}
if ( window.localStorage.hasOwnProperty("lastzoom") ) {
startzoom = window.localStorage.getItem("lastzoom");
}
// if ( window.localStorage.hasOwnProperty("clusterat") ) {
// clusterAt = window.localStorage.getItem("clusterat");
// document.getElementById("setclus").value = clusterAt;
// }
if ( window.localStorage.hasOwnProperty("maxage") ) {
maxage = window.localStorage.getItem("maxage");
document.getElementById("maxage").value = maxage;
if (showUserMenu) {
if ( window.localStorage.hasOwnProperty("lastpos") ) {
var sp = JSON.parse(window.localStorage.getItem("lastpos"));
startpos = [ sp.lat, sp.lng ];
}
if ( window.localStorage.hasOwnProperty("lastzoom") ) {
startzoom = window.localStorage.getItem("lastzoom");
}
// if ( window.localStorage.hasOwnProperty("clusterat") ) {
// clusterAt = window.localStorage.getItem("clusterat");
// document.getElementById("setclus").value = clusterAt;
// }
if ( window.localStorage.hasOwnProperty("maxage") ) {
maxage = window.localStorage.getItem("maxage");
document.getElementById("maxage").value = maxage;
}
}
// Create the Initial Map object.
@ -266,7 +266,7 @@ if (window.self !== window.top) {
(document.getElementById("menu").style.borderRadius="6px");
}
else {
console.log("NOT in an iframe")
console.log("NOT in an iframe");
// window.onbeforeunload = function(e) {
// return 'Reloading will delete all the local markers, including any drawing on the "drawing" layer';
// };
@ -278,12 +278,10 @@ else {
if (!inIframe) {
// Add the fullscreen button
L.control.fullscreen().addTo(map);
// map.on('fullscreenchange', function () {
// if (map.isFullscreen()) { console.log('entered fullscreen') }
// else { console.log('exited fullscreen'); }
// });
// Add the locate my position button
L.easyButton( 'fa-crosshairs fa-lg', function() {
map.locate({setView:true, maxZoom:16});
@ -873,9 +871,11 @@ overlays["ship nav"] = L.tileLayer('https://tiles.openseamap.org/seamark/{z}/{x}
attribution: 'Map data: &copy; <a href="https://www.openseamap.org">OpenSeaMap</a> contributors'
});
if ( window.localStorage.hasOwnProperty("lastlayer") ) {
if ( basemaps[window.localStorage.getItem("lastlayer")] ) {
baselayername = window.localStorage.getItem("lastlayer");
if (showUserMenu) {
if ( window.localStorage.hasOwnProperty("lastlayer") ) {
if ( basemaps[window.localStorage.getItem("lastlayer")] ) {
baselayername = window.localStorage.getItem("lastlayer");
}
}
}
basemaps[baselayername].addTo(map);
@ -1456,10 +1456,6 @@ function setMarker(data) {
// handle any incoming COMMANDS to control the map remotely
function doCommand(cmd) {
//console.log("COMMAND",cmd);
// ignore server side initial command if client position already saved.
// if (cmd.hasOwnProperty("init") && initialposition) {
// return;
// }
if (cmd.hasOwnProperty("clear")) {
doTidyUp(cmd.clear);
}
@ -1468,39 +1464,27 @@ function doCommand(cmd) {
else { panit = false; }
document.getElementById("panit").checked = panit;
}
if (cmd.hasOwnProperty("panlock")) {
if (cmd.panlock == "true" || cmd.panlock == true) { lockit = false; }
else { lockit = true; }
doLock();
document.getElementById("lockit").checked = !lockit;
}
if (cmd.hasOwnProperty("hiderightclick")) {
if (cmd.hiderightclick == "true" || cmd.hiderightclick == true) { hiderightclick = true; }
else { hiderightclick = false; }
}
if (cmd.hasOwnProperty("zoomlock")) {
if (cmd.zoomlock == "true" || cmd.zoomlock == true) {
if (map.doubleClickZoom.enabled()) { map.removeControl(map.zoomControl); }
map.doubleClickZoom.disable();
map.scrollWheelZoom.disable();
}
else {
if (!map.doubleClickZoom.enabled()) { map.addControl(map.zoomControl); }
map.doubleClickZoom.enable();
map.scrollWheelZoom.enable();
}
}
if (cmd.hasOwnProperty("showmenu")) {
if ((cmd.showmenu === "hide") && (showUserMenu === true)) {
showUserMenu = false;
if (menuButton) {
try { map.removeControl(menuButton); }
catch(e) {}
if (inIframe) {
if (menuButton) {
try { map.removeControl(menuButton); }
catch(e) {}
}
}
else { document.getElementById("bars").style.display="none"; }
}
else if ((cmd.showmenu === "show") && (showUserMenu === false)) {
showUserMenu = true;
map.addControl(menuButton);
if (inIframe) {
map.addControl(menuButton);
}
else { document.getElementById("bars").style.display="unset"; }
}
}
if (cmd.hasOwnProperty("showlayers")) {
@ -1529,20 +1513,18 @@ function doCommand(cmd) {
}
}
if (cmd.hasOwnProperty("coords")) {
if (cmd.coords === "dms" && showMouseCoords === false) {
try { coords.removeFrom(map); }
catch(e) {}
if (cmd.coords == "dms") {
coords.options.useDMS = true;
showMouseCoords = true;
showMouseCoords = "dms";
coords.addTo(map);
}
if (cmd.coords === "deg" && showMouseCoords === false) {
if (cmd.coords == "deg") {
coords.options.useDMS = false;
showMouseCoords = true;
showMouseCoords = "deg";
coords.addTo(map);
}
if (cmd.coords === "none" && showMouseCoords === true) {
showMouseCoords = false
coords.removeFrom(map);
}
}
var existsalready = false;
@ -1804,12 +1786,21 @@ function doCommand(cmd) {
}
}
}
if (cmd.hasOwnProperty("panlock")) {
if (cmd.panlock == "true" || cmd.panlock == true) { lockit = false; }
else { lockit = true; doLock(); }
document.getElementById("lockit").checked = !lockit;
}
// move to a new position
var clat = map.getCenter().lat;
var clon = map.getCenter().lng;
var czoom = map.getZoom();
if (cmd.hasOwnProperty("lat")) { clat = cmd.lat; }
if (cmd.hasOwnProperty("lon")) { clon = cmd.lon; }
if (cmd.hasOwnProperty("zoom")) { czoom = cmd.zoom; }
map.setView([clat,clon],czoom);
if (cmd.hasOwnProperty("cluster")) {
clusterAt = cmd.cluster;
document.getElementById("setclus").value = cmd.cluster;
@ -1824,7 +1815,19 @@ function doCommand(cmd) {
document.getElementById("heatall").checked = !!cmd.heatmap;
heat.redraw();
}
map.setView([clat,clon],czoom);
if (cmd.hasOwnProperty("panlock") && lockit === false) { doLock(); }
if (cmd.hasOwnProperty("zoomlock")) {
if (cmd.zoomlock == "true" || cmd.zoomlock == true) {
if (map.doubleClickZoom.enabled()) { map.removeControl(map.zoomControl); }
map.doubleClickZoom.disable();
map.scrollWheelZoom.disable();
}
else {
if (!map.doubleClickZoom.enabled()) { map.addControl(map.zoomControl); }
map.doubleClickZoom.enable();
map.scrollWheelZoom.enable();
}
}
}
// handle any incoming GEOJSON directly - may style badly

View File

@ -1,5 +1,5 @@
CACHE MANIFEST
# date: Mar 2nd 2019 - v1.5.30
# date: Mar 14th 2019 - v1.5.31
CACHE:
index.html