diff --git a/worldmap/index.html b/worldmap/index.html index 35da4b0..d71a60e 100644 --- a/worldmap/index.html +++ b/worldmap/index.html @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -62,7 +62,7 @@
- + Node-RED - map all the things
@@ -147,7 +147,7 @@ var iconSz = { // Create the socket var connect = function() { - ws = new SockJS(location.pathname + 'socket'); + ws = new SockJS(location.pathname.split("index")[0] + 'socket'); ws.onopen = function() { console.log("CONNECTED"); if (!inIframe) { @@ -183,6 +183,14 @@ var connect = function() { console.log("CONNECT TO",location.pathname + 'socket'); connect(); +document.addEventListener ("keydown", function (ev) { + if (ev.ctrlKey && ev.altKey && ev.code === "Digit3") { + ws.close(); + window.onbeforeunload = null; + window.location.href = "index3d.html"; + } +}); + if ( window.localStorage.hasOwnProperty("lastpos") ) { initialposition = true; var sp = JSON.parse(window.localStorage.getItem("lastpos")); @@ -552,85 +560,85 @@ map.on('locationerror', onLocationError); // Add all the base layer maps // Use this for OSM online maps -var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; -//var osmUrl='http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png'; +var osmUrl='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; +//var osmUrl='https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png'; var osmAttrib='Map data © OpenStreetMap contributors'; var osmg = new L.TileLayer.Grayscale(osmUrl, {attribution:osmAttrib, maxNativeZoom:19, maxZoom:20}); basemaps["OSM grey"] = osmg; var osm = new L.TileLayer(osmUrl, {attribution:osmAttrib, maxNativeZoom:19, maxZoom:20}); basemaps["OSM"] = osm; -// Extra Leaflet map layers from http://leaflet-extras.github.io/leaflet-providers/preview/ -var Esri_WorldStreetMap = L.tileLayer('http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', { +// Extra Leaflet map layers from https://leaflet-extras.github.io/leaflet-providers/preview/ +var Esri_WorldStreetMap = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © Esri', maxNativeZoom:19, maxZoom:20 }); basemaps["Esri"] = Esri_WorldStreetMap; -var Esri_WorldImagery = L.tileLayer('http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', { +var Esri_WorldImagery = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', { attribution:'Tiles © Esri', maxNativeZoom:19, maxZoom:20 }); basemaps["Esri Satellite"] = Esri_WorldImagery; -var Esri_WorldShadedRelief = L.tileLayer('http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}', { +var Esri_WorldShadedRelief = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © Esri', maxNativeZoom:13 }); basemaps["Esri Terrain"] = Esri_WorldShadedRelief; -var Esri_OceanBasemap = L.tileLayer('http://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}', { +var Esri_OceanBasemap = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © Esri', maxNativeZoom:10 }); basemaps["Esri Ocean"] = Esri_OceanBasemap; -// var OpenMapSurfer_Roads = L.tileLayer('http://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}', { +// var OpenMapSurfer_Roads = L.tileLayer('https://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}', { // maxZoom: 18, -// attribution: 'Imagery from University of Heidelberg — Map data © OpenStreetMap' +// attribution: 'Imagery from University of Heidelberg — Map data © OpenStreetMap' // }); // basemaps["Mapsurfer"] = OpenMapSurfer_Roads; -// var MapQuestOpen_OSM = L.tileLayer('http://otile{s}.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.{ext}', { +// var MapQuestOpen_OSM = L.tileLayer('https://otile{s}.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.{ext}', { // type: 'map', // ext: 'jpg', -// attribution: 'Tiles Courtesy of MapQuest — Map data © OpenStreetMap', +// attribution: 'Tiles Courtesy of MapQuest — Map data © OpenStreetMap', // subdomains: '1234', // maxNativeZoom: 17 // }); //basemaps["MapQuest OSM"] = MapQuestOpen_OSM; -var Esri_NatGeoWorldMap = L.tileLayer('http://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}', { +var Esri_NatGeoWorldMap = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © Esri', maxNativeZoom:12 }); basemaps["Nat Geo"] = Esri_NatGeoWorldMap; -var NLS_OS_opendata = L.tileLayer('http://geo.nls.uk/maps/opendata/{z}/{x}/{y}.png', { - attribution: 'National Library of Scotland Historic Maps', +var NLS_OS_opendata = L.tileLayer('https://geo.nls.uk/maps/opendata/{z}/{x}/{y}.png', { + attribution: 'National Library of Scotland Historic Maps', bounds: [[49.6, -12], [61.7, 3]], minZoom:1, maxNativeZoom:18, maxZoom:18, subdomains: '0123' }); basemaps["UK OS Opendata"] = NLS_OS_opendata; -var NLS_OS_1919_1947 = L.tileLayer( 'http://nls-{s}.tileserver.com/nls/{z}/{x}/{y}.jpg', { - attribution: 'Historical Maps Layer, from NLS Maps', +var NLS_OS_1919_1947 = L.tileLayer( 'https://nls-{s}.tileserver.com/nls/{z}/{x}/{y}.jpg', { + attribution: 'Historical Maps Layer, from NLS Maps', bounds: [[49.6, -12], [61.7, 3]], minZoom:1, maxZoom:18, subdomains: '0123' }); basemaps["UK OS 1919-47"] = NLS_OS_1919_1947; -//var NLS_OS_1900 = L.tileLayer('http://nls-{s}.tileserver.com/NLS_API/{z}/{x}/{y}.jpg', { -var NLS_OS_1900 = L.tileLayer('http://nls-{s}.tileserver.com/fpsUZbzrfb5d/{z}/{x}/{y}.jpg', { - attribution: 'National Library of Scotland Historic Maps', +//var NLS_OS_1900 = L.tileLayer('https://nls-{s}.tileserver.com/NLS_API/{z}/{x}/{y}.jpg', { +var NLS_OS_1900 = L.tileLayer('https://nls-{s}.tileserver.com/fpsUZbzrfb5d/{z}/{x}/{y}.jpg', { + attribution: 'National Library of Scotland Historic Maps', bounds: [[49.6, -12], [61.7, 3]], minZoom:1, maxNativeZoom:19, maxZoom:20, subdomains: '0123' }); basemaps["UK OS 1900"] = NLS_OS_1900; -//var CartoPos = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', { -// attribution: '© OpenStreetMap contributors, © CartoDB' +//var CartoPos = L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', { +// attribution: '© OpenStreetMap contributors, © CartoDB' //}); //basemaps["CartoDB Light"] = CartoPos; @@ -679,10 +687,10 @@ map.on('draw:created', function (e) { }); // // Add the roads overlay -// overlays["roads"] = L.tileLayer('http://otile{s}.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.{ext}', { +// overlays["roads"] = L.tileLayer('https://otile{s}.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.{ext}', { // type: 'hyb', // ext: 'png', -// attribution: 'MapQuest — Map data © OpenStreetMap', +// attribution: 'MapQuest — Map data © OpenStreetMap', // subdomains: '1234', // opacity: 0.9 // }); @@ -692,8 +700,8 @@ overlays["buildings"] = new OSMBuildings(map).load(); map.removeLayer(overlays["buildings"]); // Hide it at start // Add the shipping navigation markers -//var OpenSeaMap = L.tileLayer('http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png', { -// attribution: 'Map data: © OpenSeaMap contributors' +//var OpenSeaMap = L.tileLayer('https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png', { +// attribution: 'Map data: © OpenSeaMap contributors' //}); //overlays["ship nav"] = OpenSeaMap; @@ -860,13 +868,13 @@ function setMarker(data) { color: (data.iconColor || "blue") }); marker.setHeading(data.hdg||data.bearing); - q = 'http://www.bing.com/images/search?q='+data.icon+'%20%2B"'+encodeURIComponent(data.name)+'"'; + q = 'https://www.bing.com/images/search?q='+data.icon+'%20%2B"'+encodeURIComponent(data.name)+'"'; words += 'Pictures
'; } else if (data.icon === "plane") { data.iconColor = data.iconColor || "black"; if (data.hasOwnProperty("squawk")) { data.iconColor = "red"; } - icon = ''; + icon = ''; icon += ''; var svgplane = "data:image/svg+xml;base64," + btoa(icon); var dir = data.hdg || data.bearing; @@ -876,13 +884,13 @@ function setMarker(data) { html:'', }); marker = L.marker(ll, {title:data.name, icon:myMarker}); - //q = 'http://www.bing.com/images/search?q='+data.icon+'%20'+encodeURIComponent(data.name); + //q = 'https://www.bing.com/images/search?q='+data.icon+'%20'+encodeURIComponent(data.name); //words += 'Pictures
'; } else if (data.icon === "uav") { data.iconColor = data.iconColor || "black"; if (data.hasOwnProperty("squawk")) { data.iconColor = "red"; } - icon = ''; + icon = ''; icon+= ''; var svguav = "data:image/svg+xml;base64," + btoa(icon); var dir = data.hdg || data.bearing; @@ -895,7 +903,7 @@ function setMarker(data) { } else if (data.icon === "car") { data.iconColor = data.iconColor || "black"; - icon = ''; + icon = ''; icon += ''; var svgcar = "data:image/svg+xml;base64," + btoa(icon); var dir = data.hdg || data.bearing; @@ -908,7 +916,7 @@ function setMarker(data) { } else if (data.icon === "arrow") { data.iconColor = data.iconColor || "black"; - icon = ''; + icon = ''; icon += ''; var svgarrow = "data:image/svg+xml;base64," + btoa(icon); var dir = data.hdg || data.bearing; @@ -921,7 +929,7 @@ function setMarker(data) { } else if (data.icon === "wind") { data.iconColor = data.iconColor || "black"; - icon = ''; + icon = ''; icon += ''; var svgwind = "data:image/svg+xml;base64," + btoa(icon); var dir = data.hdg || data.bearing; @@ -934,7 +942,7 @@ function setMarker(data) { } else if (data.icon === "satellite") { data.iconColor = data.iconColor || "black"; - icon = ''; + icon = ''; icon += ''; icon += ''; icon += ''; @@ -951,7 +959,7 @@ function setMarker(data) { } else if (data.icon === "locate") { data.iconColor = data.iconColor || "cyan"; - icon = ''; + icon = ''; icon += ''; icon += ''; icon += ''; @@ -1056,6 +1064,10 @@ function setMarker(data) { } delete data.weblink; } + + popped = stay; + + // Add any remaining properties to the info box for (var i in data) { if ((i != "name") && (i != "length")) { if (typeof data[i] === "object") { @@ -1080,11 +1092,6 @@ function setMarker(data) { layers[lay].addLayer(marker); } - popped = stay; - if (popped) { - if (popid == data.name) { marker.openPopup(); } - else { popmark.openPopup(); } - } if ((data.hdg != null) && (data.bearing == null)) { data.bearing = data.hdg; delete data.hdg; } if (data.bearing != null) { // if there is a heading if (data.speed != null) { data.length = data.speed * 50; } // and a speed @@ -1125,6 +1132,10 @@ function setMarker(data) { if (panit) { map.setView(ll,map.getZoom()); } + if (popped) { + if (popid == data.name) { marker.openPopup(); } + else { popmark.openPopup(); } + } } } @@ -1254,7 +1265,7 @@ function doCommand(cmd) { layercontrol.addOverlay(overlays[cmd.map.overlay],cmd.map.overlay); } map.addLayer(overlays[cmd.map.overlay]); - if (cmd.map.hasOwnProperty("fit")) { map.fitBounds(overlays[cmd.map.overlay].getBounds()); } + if (cmd.map.hasOwnProperty("fit")) { map.fitBounds(overlays[cmd.map.overlay].getBounds()); } } // Add a new overlay layer if (cmd.map && cmd.map.hasOwnProperty("overlay") && cmd.map.hasOwnProperty("url") && cmd.map.hasOwnProperty("opt")) {