diff --git a/worldmap/index.html b/worldmap/index.html index 4eb3010..909b4e9 100644 --- a/worldmap/index.html +++ b/worldmap/index.html @@ -67,7 +67,7 @@ - +
Node-RED - map all the things @@ -80,14 +80,13 @@   Set Max Age s Cluster at zoom < - Auto Pan Map - Lock Map - Heatmap all layers + Auto Pan Map + Lock Map + Heatmap all layers Help
-

Node-RED - Map all the things

@@ -207,13 +206,13 @@ console.log("CONNECT TO",location.pathname + 'socket'); connect(); var onoffline = function() { - if (!navigator.onLine) { map.addLayer(layers["_countries"]); } + if (!navigator.onLine) { map.addLayer(layers["_countries"]); } } +// Set Ctl-Alt-3 to switch to 3d view document.addEventListener ("keydown", function (ev) { - if (ev.ctrlKey && ev.altKey && ev.code === "Digit3") { + if (ev.ctrlKey && ev.altKey && ev.code === "Digit3") { ws.close(); - //window.onbeforeunload = null; window.location.href = "index3d.html"; } }); @@ -276,15 +275,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}); }, "Locate me").addTo(map); - // Add the measure/ruler button L.Control.measureControl().addTo(map); @@ -297,7 +291,7 @@ if (!inIframe) { else { if (showUserMenu) { menuButton.addTo(map); } } -// Handle the dialog for popup help +// Handle the dialog for help box var dialog = document.querySelector('dialog'); dialogPolyfill.registerDialog(dialog); document.getElementById('showHelp').onclick = function() { @@ -308,26 +302,25 @@ document.getElementById('exitHelp').onclick = function() { }; var panit = false; -function doPanit() { - panit = !panit; +function doPanit(v) { + if (v !== undefined) { panit = v; } console.log("Panit set :",panit); } var heatAll = false; -function doHeatAll() { - heatAll = !heatAll; +function doHeatAll(v) { + if (v !== undefined) { heatall = v; } console.log("Heatall set :",heatAll); } var lockit = false; var mb = new L.LatLngBounds([[-120,-360],[120,360]]); -function doLock() { - if (lockit === true) { - lockit = false; +function doLock(v) { + if (v !== undefined) { lockit = v; } + if (lockit === false) { mb = new L.LatLngBounds([[-120,-360],[120,360]]); } else { - lockit = true; mb = map.getBounds(); window.localStorage.setItem("lastpos",JSON.stringify(map.getCenter())); window.localStorage.setItem("lastzoom", map.getZoom()); @@ -372,7 +365,7 @@ function setMaxAge() { maxage = document.getElementById('maxage').value; if (stale) { clearInterval(stale); } //if (maxage > 0) { - stale = setInterval( function() { doTidyUp() }, 20000); // every 20 secs + stale = setInterval( function() { doTidyUp() }, 20000); // check every 20 secs //} //every minute //console.log("Stale time set :",maxage+"s"); } @@ -393,7 +386,7 @@ function setCluster(v) { showMapCurrentZoom(); } -// Search for markers with names of .... +// Search for markers with names of ... or icons of ... function doSearch() { var value = document.getElementById('search').value; marks = []; @@ -488,18 +481,18 @@ function toggleMenu() { } } -function openMenu(){ - if (!menuOpen) { - menuOpen = true; - document.getElementById("menu").style.display = 'block'; - } +function openMenu() { + if (!menuOpen) { + menuOpen = true; + document.getElementById("menu").style.display = 'block'; + } } -function closeMenu(){ - if (menuOpen) { - menuOpen = false; - document.getElementById("menu").style.display = 'none'; - } +function closeMenu() { + if (menuOpen) { + menuOpen = false; + document.getElementById("menu").style.display = 'none'; + } } document.getElementById("menu").style.display = 'none'; @@ -517,12 +510,12 @@ document.getElementById("menu").style.display = 'none'; // popmark = e.popup._source; // popid = e.popup.dname; // }); -map.on('popupopen', function(e) { - console.log("OPEN",e); -}); -map.on('popupclose', function(e) { - console.log("CLOSE",e); -}); +// map.on('popupopen', function(e) { +// console.log("OPEN",e); +// }); +// map.on('popupclose', function(e) { +// console.log("CLOSE",e); +// }); map.on('overlayadd', function(e) { if (typeof overlays[e.name].bringToFront === "function") { @@ -538,7 +531,6 @@ map.on('overlayadd', function(e) { clrHeat.addTo(map); } if (e.name == "day/night") { - //console.log("add daynight"); layers["_daynight"].addLayer(L.terminator()); } if (e.name == "drawing") { @@ -556,14 +548,12 @@ map.on('overlayremove', function(e) { clrHeat.removeFrom(map); } if (e.name == "day/night") { - //console.log("del daynight"); layers["_daynight"].clearLayers(); } if (e.name == "drawing") { //map.removeControl(colorControl); map.removeControl(drawControl); } - //else console.log("layer del :",e.name); ws.send(JSON.stringify({action:"dellayer", name:e.name})); }); @@ -814,11 +804,6 @@ overlays["countries"] = layers["_countries"]; layers["_daynight"] = new L.LayerGroup(); overlays["day/night"] = layers["_daynight"]; -// Add the heatmap layer -var heat = L.heatLayer([], {radius:60, gradient:{0.2:'blue', 0.4:'lime', 0.6:'red', 0.8:'yellow', 1:'white'}}); -layers["_heat"] = new L.LayerGroup().addLayer(heat); -overlays["heatmap"] = layers["_heat"]; - // Add the drawing layer for fun... layers["_drawing"] = new L.FeatureGroup(); overlays["drawing"] = layers["_drawing"]; @@ -827,7 +812,8 @@ var drawControl = new L.Control.Draw({ polyline: { shapeOptions: { clickable:false } }, marker: false, circle: false, - //circle: { shapeOptions: { clickable:false } }, + // circle: { shapeOptions: { clickable:false } }, + circlemarker: false, rectangle: { shapeOptions: { clickable:true } }, polygon: { shapeOptions: { clickable:true } }, }, @@ -846,7 +832,12 @@ map.on('draw:created', function (e) { layers["_drawing"].addLayer(layer); }); +// Add the heatmap layer +var heat = L.heatLayer([], {radius:60, gradient:{0.2:'blue', 0.4:'lime', 0.6:'red', 0.8:'yellow', 1:'white'}}); +layers["_heat"] = new L.LayerGroup().addLayer(heat); +overlays["heatmap"] = layers["_heat"]; +// Add the buildings layer overlays["buildings"] = new OSMBuildings(map).load(); map.removeLayer(overlays["buildings"]); // Hide it at start @@ -1351,7 +1342,6 @@ function setMarker(data) { var rightcontext = ""; if (data.contextmenu && (typeof data.contextmenu === "string")) { rightcontext = data.contextmenu.replace(/$name/g,'\""+'+data.name+'+"\"'); - console.log("RC",rightcontext); delete data.contextmenu; } var openpop; @@ -1383,13 +1373,15 @@ function setMarker(data) { marker._popup.dname = data.name; marker.lay = lay; // and the layer it is on - var rightmenuMarker = L.popup({offset:[0,-12]}).setContent(""+data.name+"
"+rightcontext); - marker.on('contextmenu', function(e) { - if (hiderightclick !== true) { - rightmenuMarker.setLatLng(e.latlng); - map.openPopup(rightmenuMarker); - } - }); + if (rightcontext.length > 0) { + var rightmenuMarker = L.popup({offset:[0,-12]}).setContent(""+data.name+"
"+rightcontext); + marker.on('contextmenu', function(e) { + if (hiderightclick !== true) { + rightmenuMarker.setLatLng(e.latlng); + map.openPopup(rightmenuMarker); + } + }); + } marker.on('click', function(e) { ws.send(JSON.stringify({action:"click",name:marker.name,layer:marker.lay,icon:marker.icon,iconColor:marker.iconColor,SIDC:marker.SIDC,draggable:true,lat:parseFloat(marker.getLatLng().lat.toFixed(6)),lon:parseFloat(marker.getLatLng().lng.toFixed(6))})); }); @@ -1795,9 +1787,9 @@ 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; + if (cmd.panlock == "true" || cmd.panlock == true) { lockit = true; } + else { lockit = false; doLock(false); } + document.getElementById("lockit").checked = lockit; } // move to a new position var clat = map.getCenter().lat; @@ -1822,7 +1814,7 @@ function doCommand(cmd) { document.getElementById("heatall").checked = !!cmd.heatmap; heat.redraw(); } - if (cmd.hasOwnProperty("panlock") && lockit === false) { doLock(); } + if (cmd.hasOwnProperty("panlock") && lockit === true) { doLock(true); } if (cmd.hasOwnProperty("zoomlock")) { if (cmd.zoomlock == "true" || cmd.zoomlock == true) { if (map.doubleClickZoom.enabled()) { map.removeControl(map.zoomControl); } diff --git a/worldmap/worldmap.appcache b/worldmap/worldmap.appcache index 71f1847..7f7385f 100644 --- a/worldmap/worldmap.appcache +++ b/worldmap/worldmap.appcache @@ -1,5 +1,5 @@ CACHE MANIFEST -# date: Mar 11th 2019 - v2.0.0h +# date: Mar 11th 2019 - v2.0.0a CACHE: index.html