node-red-contrib-web-worldmap 2.20.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/README.md +2 -0
- package/node_modules/@turf/bezier-spline/dist/es/index.js +7 -3
- package/node_modules/@turf/bezier-spline/dist/es/lib/spline.js +0 -0
- package/node_modules/@turf/bezier-spline/dist/js/index.d.ts +0 -0
- package/node_modules/@turf/bezier-spline/dist/js/index.js +7 -3
- package/node_modules/@turf/bezier-spline/dist/js/lib/spline.d.ts +1 -1
- package/node_modules/@turf/bezier-spline/dist/js/lib/spline.js +0 -0
- package/node_modules/@turf/bezier-spline/package.json +23 -19
- package/node_modules/@turf/helpers/dist/es/index.js +2 -2
- package/node_modules/@turf/helpers/dist/es/lib/geojson.js +0 -0
- package/node_modules/@turf/helpers/dist/js/index.d.ts +1 -1
- package/node_modules/@turf/helpers/dist/js/index.js +2 -2
- package/node_modules/@turf/helpers/dist/js/lib/geojson.d.ts +0 -0
- package/node_modules/@turf/helpers/dist/js/lib/geojson.js +0 -0
- package/node_modules/@turf/helpers/package.json +22 -18
- package/node_modules/@turf/invariant/dist/es/index.js +0 -0
- package/node_modules/@turf/invariant/dist/js/index.d.ts +0 -0
- package/node_modules/@turf/invariant/dist/js/index.js +0 -0
- package/node_modules/@turf/invariant/package.json +22 -18
- package/node_modules/accepts/package.json +13 -10
- package/node_modules/array-flatten/package.json +8 -5
- package/node_modules/body-parser/node_modules/bytes/package.json +8 -5
- package/node_modules/body-parser/package.json +8 -5
- package/node_modules/bufferjs/package.json +13 -10
- package/node_modules/bufferlist/package.json +13 -13
- package/node_modules/cgi/package.json +7 -4
- package/node_modules/compressible/package.json +4 -4
- package/node_modules/compression/node_modules/bytes/package.json +4 -4
- package/node_modules/compression/package.json +12 -9
- package/node_modules/content-disposition/package.json +8 -5
- package/node_modules/content-type/package.json +13 -10
- package/node_modules/cookie/package.json +8 -5
- package/node_modules/cookie-signature/package.json +8 -5
- package/node_modules/debug/package.json +13 -10
- package/node_modules/depd/package.json +13 -10
- package/node_modules/destroy/package.json +13 -10
- package/node_modules/ee-first/package.json +8 -5
- package/node_modules/encodeurl/package.json +13 -10
- package/node_modules/escape-html/package.json +13 -10
- package/node_modules/etag/package.json +13 -10
- package/node_modules/express/package.json +12 -9
- package/node_modules/extend/package.json +13 -10
- package/node_modules/faye-websocket/package.json +13 -10
- package/node_modules/finalhandler/package.json +13 -10
- package/node_modules/forwarded/package.json +13 -10
- package/node_modules/fresh/package.json +8 -5
- package/node_modules/header-stack/package.json +13 -10
- package/node_modules/header-stack/parser.js +2 -2
- package/node_modules/http-errors/package.json +8 -5
- package/node_modules/iconv-lite/package.json +8 -5
- package/node_modules/inherits/package.json +8 -5
- package/node_modules/ipaddr.js/package.json +4 -4
- package/node_modules/media-typer/package.json +8 -5
- package/node_modules/merge-descriptors/package.json +8 -5
- package/node_modules/methods/package.json +13 -10
- package/node_modules/mime/package.json +8 -5
- package/node_modules/mime-db/package.json +5 -5
- package/node_modules/mime-types/package.json +5 -5
- package/node_modules/ms/package.json +8 -5
- package/node_modules/negotiator/package.json +8 -5
- package/node_modules/on-finished/package.json +13 -10
- package/node_modules/on-headers/package.json +13 -10
- package/node_modules/parseurl/package.json +13 -10
- package/node_modules/path-to-regexp/package.json +8 -5
- package/node_modules/proxy-addr/package.json +4 -4
- package/node_modules/qs/package.json +8 -5
- package/node_modules/range-parser/package.json +13 -10
- package/node_modules/raw-body/node_modules/bytes/package.json +8 -5
- package/node_modules/raw-body/package.json +8 -5
- package/node_modules/safe-buffer/package.json +8 -5
- package/node_modules/safer-buffer/package.json +13 -10
- package/node_modules/send/node_modules/ms/package.json +8 -5
- package/node_modules/send/package.json +8 -5
- package/node_modules/serve-static/package.json +8 -5
- package/node_modules/setprototypeof/package.json +8 -5
- package/node_modules/sockjs/package.json +12 -9
- package/node_modules/statuses/package.json +13 -10
- package/node_modules/stream-stack/package.json +13 -10
- package/node_modules/toidentifier/package.json +8 -5
- package/node_modules/type-is/package.json +13 -10
- package/node_modules/unpipe/package.json +8 -5
- package/node_modules/utils-merge/package.json +8 -5
- package/node_modules/uuid/package.json +13 -10
- package/node_modules/vary/package.json +13 -10
- package/node_modules/websocket-driver/lib/websocket/driver/base.js +2 -0
- package/node_modules/websocket-driver/node_modules/http-parser-js/package.json +4 -4
- package/node_modules/websocket-driver/package.json +13 -10
- package/node_modules/websocket-extensions/package.json +13 -10
- package/package.json +3 -3
- package/worldmap/leaflet/leaflet.css +2 -2
- package/worldmap/leaflet/leaflet.js.map +1 -0
- package/worldmap/leaflet/leaflet.latlng-graticule.js +23 -21
- package/worldmap/worldmap.js +415 -331
- package/worldmap.html +206 -107
- package/worldmap.js +23 -7
package/worldmap/worldmap.js
CHANGED
|
@@ -24,6 +24,7 @@ var showUserMenu = true;
|
|
|
24
24
|
var showLayerMenu = true;
|
|
25
25
|
var showMouseCoords = false;
|
|
26
26
|
var allowFileDrop = false;
|
|
27
|
+
var heat;
|
|
27
28
|
var minimap;
|
|
28
29
|
var sidebyside;
|
|
29
30
|
var layercontrol;
|
|
@@ -112,7 +113,9 @@ var handleData = function(data) {
|
|
|
112
113
|
if (data.hasOwnProperty("type") && data.type.indexOf("Feature") === 0) { doGeojson("geojson",data); }
|
|
113
114
|
else if (data.hasOwnProperty("name")) { setMarker(data); }
|
|
114
115
|
else {
|
|
115
|
-
|
|
116
|
+
if (JSON.stringify(data) !== '{}') {
|
|
117
|
+
console.log("SKIP",data);
|
|
118
|
+
}
|
|
116
119
|
// if (typeof data === "string") { doDialog(data); }
|
|
117
120
|
// else { console.log("SKIP",data); }
|
|
118
121
|
}
|
|
@@ -410,7 +413,7 @@ setMaxAge();
|
|
|
410
413
|
|
|
411
414
|
// move the daylight / nighttime boundary (if enabled) every minute
|
|
412
415
|
function moveTerminator() { // if terminator line plotted move it every minute
|
|
413
|
-
if (layers["_daynight"].getLayers().length > 0) {
|
|
416
|
+
if (layers["_daynight"] && layers["_daynight"].getLayers().length > 0) {
|
|
414
417
|
layers["_daynight"].clearLayers();
|
|
415
418
|
layers["_daynight"].addLayer(L.terminator());
|
|
416
419
|
}
|
|
@@ -590,7 +593,7 @@ map.on('baselayerchange', function(e) {
|
|
|
590
593
|
});
|
|
591
594
|
|
|
592
595
|
function showMapCurrentZoom() {
|
|
593
|
-
console.log("zoom:",map.getZoom()
|
|
596
|
+
//console.log("zoom:",map.getZoom());
|
|
594
597
|
for (var l in layers) {
|
|
595
598
|
if (layers[l].hasOwnProperty("_zoom")) {
|
|
596
599
|
if (map.getZoom() >= clusterAt) {
|
|
@@ -727,378 +730,453 @@ map.on('contextmenu', function(e) {
|
|
|
727
730
|
}
|
|
728
731
|
});
|
|
729
732
|
|
|
730
|
-
// Add all the base layer maps
|
|
731
|
-
|
|
733
|
+
// Add all the base layer maps if we are online.
|
|
734
|
+
var addBaseMaps = function(maplist,first) {
|
|
735
|
+
//console.log("MAPS",first,maplist)
|
|
736
|
+
if (navigator.onLine) {
|
|
737
|
+
var layerlookup = { OSMG:"OSM grey", OSMC:"OSM", OSMH:"OSM Humanitarian", EsriC:"Esri", EsriS:"Esri Satellite",
|
|
738
|
+
EsriT:"Esri Topography", EsriO:"Esri Ocean", EsriDG:"Esri Dark Grey", NatGeo: "National Geographic",
|
|
739
|
+
UKOS:"UK OS OpenData", UKOS45:"UK OS 1919-1947", UKOS00:"UK OS 1900", OpTop:"Open Topo Map",
|
|
740
|
+
HB:"Hike Bike OSM", ST:"Stamen Topography", SW: "Stamen Watercolor", AN:"AutoNavi (Chinese)" }
|
|
741
|
+
|
|
742
|
+
// Use this for OSM online maps
|
|
743
|
+
var osmUrl='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
|
744
|
+
var osmAttrib='Map data © OpenStreetMap contributors';
|
|
745
|
+
|
|
746
|
+
if (maplist.indexOf("OSMG")!==-1) {
|
|
747
|
+
basemaps[layerlookup["OSMG"]] = new L.TileLayer.Grayscale(osmUrl, {
|
|
748
|
+
attribution:osmAttrib,
|
|
749
|
+
maxNativeZoom:19,
|
|
750
|
+
maxZoom:20,
|
|
751
|
+
subdomains: ['a','b','c']
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
if (maplist.indexOf("OSMC")!==-1) {
|
|
755
|
+
basemaps[layerlookup["OSMC"]] = new L.TileLayer(osmUrl, {
|
|
756
|
+
attribution:osmAttrib,
|
|
757
|
+
maxNativeZoom:19,
|
|
758
|
+
maxZoom:20,
|
|
759
|
+
subdomains: ['a','b','c']
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
if (maplist.indexOf("OSMH")!==-1) {
|
|
763
|
+
basemaps[layerlookup["OSMH"]] = new L.TileLayer("https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png", {
|
|
764
|
+
attribution:"Map data © OpenStreetMap Contributors. Courtesy of Humanitarian OpenStreetMap Team",
|
|
765
|
+
maxNativeZoom:19,
|
|
766
|
+
maxZoom:20,
|
|
767
|
+
subdomains: ['a','b']
|
|
768
|
+
});
|
|
769
|
+
}
|
|
732
770
|
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
771
|
+
// Extra Leaflet map layers from https://leaflet-extras.github.io/leaflet-providers/preview/
|
|
772
|
+
if (maplist.indexOf("EsriC")!==-1) {
|
|
773
|
+
basemaps[layerlookup["EsriC"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
|
|
774
|
+
attribution:'Tiles © Esri',
|
|
775
|
+
maxNativeZoom:19,
|
|
776
|
+
maxZoom:20
|
|
777
|
+
});
|
|
778
|
+
}
|
|
739
779
|
|
|
740
|
-
|
|
741
|
-
|
|
780
|
+
if (maplist.indexOf("EsriS")!==-1) {
|
|
781
|
+
basemaps[layerlookup["EsriS"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
|
|
782
|
+
//var Esri_WorldImagery = L.tileLayer('http://clarity.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {{
|
|
783
|
+
attribution:'Tiles © Esri',
|
|
784
|
+
maxNativeZoom:17, maxZoom:20
|
|
785
|
+
});
|
|
786
|
+
}
|
|
742
787
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
788
|
+
if (maplist.indexOf("EsriT")!==-1) {
|
|
789
|
+
basemaps[layerlookup["EsriT"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
|
|
790
|
+
attribution:'Tiles © Esri — Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community'
|
|
791
|
+
});
|
|
792
|
+
}
|
|
748
793
|
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
794
|
+
if (maplist.indexOf("EsriR")!==-1) {
|
|
795
|
+
basemaps[layerlookup["EsriR"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}', {
|
|
796
|
+
attribution:'Tiles © Esri',
|
|
797
|
+
maxNativeZoom:13
|
|
798
|
+
});
|
|
799
|
+
}
|
|
754
800
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
801
|
+
if (maplist.indexOf("EsriO")!==-1) {
|
|
802
|
+
basemaps[layerlookup["EsriO"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}', {
|
|
803
|
+
attribution:'Tiles © Esri — Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri',
|
|
804
|
+
maxNativeZoom:13
|
|
805
|
+
});
|
|
806
|
+
}
|
|
759
807
|
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
808
|
+
if (maplist.indexOf("EsriDG")!==-1) {
|
|
809
|
+
basemaps[layerlookup["EsriDG"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}', {
|
|
810
|
+
attribution: 'Tiles © Esri — Esri, DeLorme, NAVTEQ',
|
|
811
|
+
maxNativeZoom:13
|
|
812
|
+
});
|
|
813
|
+
}
|
|
765
814
|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
815
|
+
if (maplist.indexOf("NatGeo")!==-1) {
|
|
816
|
+
basemaps[layerlookup["NatGeo"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}', {
|
|
817
|
+
attribution: 'Tiles © Esri',
|
|
818
|
+
maxNativeZoom:12
|
|
819
|
+
});
|
|
820
|
+
}
|
|
771
821
|
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
// attribution: 'Imagery from <a href="https://giscience.uni-hd.de/">University of Heidelberg</a> — Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
|
781
|
-
// });
|
|
782
|
-
// basemaps["Mapsurfer"] = OpenMapSurfer_Roads;
|
|
783
|
-
|
|
784
|
-
// var MapQuestOpen_OSM = L.tileLayer('https://otile{s}.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.{ext}', {
|
|
785
|
-
// type: 'map',
|
|
786
|
-
// ext: 'jpg',
|
|
787
|
-
// attribution: 'Tiles Courtesy of <a href="https://www.mapquest.com/">MapQuest</a> — Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
|
|
788
|
-
// subdomains: '1234',
|
|
789
|
-
// maxNativeZoom: 17
|
|
790
|
-
// });
|
|
791
|
-
//basemaps["MapQuest OSM"] = MapQuestOpen_OSM;
|
|
792
|
-
|
|
793
|
-
var Esri_NatGeoWorldMap = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}', {
|
|
794
|
-
attribution: 'Tiles © Esri',
|
|
795
|
-
maxNativeZoom:12
|
|
796
|
-
});
|
|
797
|
-
basemaps["Nat Geo"] = Esri_NatGeoWorldMap;
|
|
822
|
+
if (maplist.indexOf("UKOS")!==-1) {
|
|
823
|
+
basemaps[layerlookup["UKOS"]] = L.tileLayer('https://geo.nls.uk/maps/opendata/{z}/{x}/{y}.png', {
|
|
824
|
+
attribution: '<a href="https://geo.nls.uk/maps/">National Library of Scotland Historic Maps</a>',
|
|
825
|
+
bounds: [[49.6, -12], [61.7, 3]],
|
|
826
|
+
minZoom:1, maxNativeZoom:17, maxZoom:20,
|
|
827
|
+
subdomains: '0123'
|
|
828
|
+
});
|
|
829
|
+
}
|
|
798
830
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
831
|
+
if (maplist.indexOf("OpTop")!==-1) {
|
|
832
|
+
basemaps[layerlookup["OpTop"]] = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
|
|
833
|
+
subdomains: 'abc',
|
|
834
|
+
maxZoom: 19,
|
|
835
|
+
attribution: '© <a href="https://www.opentopomap.org/copyright">OpenTopoMap</a> contributors'
|
|
836
|
+
});
|
|
837
|
+
}
|
|
806
838
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
839
|
+
if (maplist.indexOf("HB")!==-1) {
|
|
840
|
+
basemaps[layerlookup["HB"]] = L.tileLayer('https://tiles.wmflabs.org/hikebike/{z}/{x}/{y}.png', {
|
|
841
|
+
maxZoom: 19,
|
|
842
|
+
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
|
843
|
+
});
|
|
844
|
+
}
|
|
813
845
|
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
846
|
+
if (maplist.indexOf("AN")!==-1) {
|
|
847
|
+
basemaps["AutoNavi"] = L.tileLayer('https://webrd01.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}', {
|
|
848
|
+
attribution: 'Tiles © 高德地图',
|
|
849
|
+
maxNativeZoom:14,
|
|
850
|
+
maxZoom: 19,
|
|
851
|
+
});
|
|
852
|
+
}
|
|
819
853
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
//var NLS_OS_1900 = L.tileLayer('https://nls-{s}.tileserver.com/NLS_API/{z}/{x}/{y}.jpg', {
|
|
829
|
-
var NLS_OS_1900 = L.tileLayer('https://nls-{s}.tileserver.com/fpsUZbzrfb5d/{z}/{x}/{y}.jpg', {
|
|
830
|
-
attribution: '<a href="https://geo.nls.uk/maps/">National Library of Scotland Historic Maps</a>',
|
|
831
|
-
bounds: [[49.6, -12], [61.7, 3]],
|
|
832
|
-
minZoom:1, maxNativeZoom:19, maxZoom:20,
|
|
833
|
-
subdomains: '0123'
|
|
834
|
-
});
|
|
835
|
-
basemaps["UK OS 1900"] = NLS_OS_1900;
|
|
836
|
-
|
|
837
|
-
//var CartoPos = L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
|
|
838
|
-
// attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="https://cartodb.com/attributions">CartoDB</a>'
|
|
839
|
-
//});
|
|
840
|
-
//basemaps["CartoDB Light"] = CartoPos;
|
|
841
|
-
|
|
842
|
-
// Nice terrain based maps by Stamen Design
|
|
843
|
-
var terrainUrl = "https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.jpg";
|
|
844
|
-
basemaps["Terrain"] = L.tileLayer(terrainUrl, {
|
|
845
|
-
subdomains: ['a','b','c','d'],
|
|
846
|
-
minZoom: 0,
|
|
847
|
-
maxZoom: 20,
|
|
848
|
-
type: 'jpg',
|
|
849
|
-
attribution: 'Map tiles by <a href="https://stamen.com">Stamen Design</a>, under <a href="https://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="https://openstreetmap.org">OpenStreetMap</a>, under <a href="https://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>'
|
|
850
|
-
});
|
|
854
|
+
if (maplist.indexOf("OS45")!==-1) {
|
|
855
|
+
basemaps[layerlookup["OS45"]] = L.tileLayer( 'https://nls-{s}.tileserver.com/nls/{z}/{x}/{y}.jpg', {
|
|
856
|
+
attribution: 'Historical Maps Layer, from <a href="https://maps.nls.uk/projects/api/">NLS Maps</a>',
|
|
857
|
+
bounds: [[49.6, -12], [61.7, 3]],
|
|
858
|
+
minZoom:1, maxZoom:18,
|
|
859
|
+
subdomains: '0123'
|
|
860
|
+
});
|
|
861
|
+
}
|
|
851
862
|
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
}
|
|
863
|
+
if (maplist.indexOf("OS00")!==-1) {
|
|
864
|
+
//var NLS_OS_1900 = L.tileLayer('https://nls-{s}.tileserver.com/NLS_API/{z}/{x}/{y}.jpg', {
|
|
865
|
+
basemaps[layerlookup["OS00"]] = L.tileLayer('https://nls-{s}.tileserver.com/fpsUZbzrfb5d/{z}/{x}/{y}.jpg', {
|
|
866
|
+
attribution: '<a href="https://geo.nls.uk/maps/">National Library of Scotland Historic Maps</a>',
|
|
867
|
+
bounds: [[49.6, -12], [61.7, 3]],
|
|
868
|
+
minZoom:1, maxNativeZoom:19, maxZoom:20,
|
|
869
|
+
subdomains: '0123'
|
|
870
|
+
});
|
|
871
|
+
}
|
|
862
872
|
|
|
873
|
+
// Nice terrain based maps by Stamen Design
|
|
874
|
+
if (maplist.indexOf("ST")!==-1) {
|
|
875
|
+
var terrainUrl = "https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.jpg";
|
|
876
|
+
basemaps[layerlookup["ST"]] = L.tileLayer(terrainUrl, {
|
|
877
|
+
subdomains: ['a','b','c','d'],
|
|
878
|
+
minZoom: 0,
|
|
879
|
+
maxZoom: 20,
|
|
880
|
+
type: 'jpg',
|
|
881
|
+
attribution: 'Map tiles by <a href="https://stamen.com">Stamen Design</a>, under <a href="https://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="https://openstreetmap.org">OpenStreetMap</a>, under <a href="https://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>'
|
|
882
|
+
});
|
|
883
|
+
}
|
|
863
884
|
|
|
864
|
-
//
|
|
885
|
+
// Nice watercolour based maps by Stamen Design
|
|
886
|
+
if (maplist.indexOf("SW")!==-1) {
|
|
887
|
+
var watercolorUrl = "https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg";
|
|
888
|
+
basemaps[layerlookup["SW"]] = L.tileLayer(watercolorUrl, {
|
|
889
|
+
subdomains: ['a','b','c','d'],
|
|
890
|
+
minZoom: 0,
|
|
891
|
+
maxZoom: 20,
|
|
892
|
+
type: 'jpg',
|
|
893
|
+
attribution: 'Map tiles by <a href="https://stamen.com">Stamen Design</a>, under <a href="https://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="https://openstreetmap.org">OpenStreetMap</a>, under <a href="https://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>'
|
|
894
|
+
});
|
|
895
|
+
}
|
|
865
896
|
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
rectangle: { shapeOptions: { clickable:true } },
|
|
879
|
-
polygon: { shapeOptions: { clickable:true } }
|
|
880
|
-
}
|
|
881
|
-
//edit: none
|
|
882
|
-
// {
|
|
883
|
-
// featureGroup: layers["_drawing"],
|
|
884
|
-
// remove: true,
|
|
885
|
-
// edit: true
|
|
886
|
-
// }
|
|
887
|
-
});
|
|
888
|
-
var changeDrawColour = function(col) {
|
|
889
|
-
drawControl.setDrawingOptions({
|
|
890
|
-
polyline: { shapeOptions: { color:col } },
|
|
891
|
-
circle: { shapeOptions: { color:col } },
|
|
892
|
-
rectangle: { shapeOptions: { color:col } },
|
|
893
|
-
polygon: { shapeOptions: { color:col } }
|
|
894
|
-
});
|
|
897
|
+
if (first) {
|
|
898
|
+
if (layerlookup[first]) { basemaps[layerlookup[first]].addTo(map); }
|
|
899
|
+
else { basemaps[first].addTo(map); }
|
|
900
|
+
}
|
|
901
|
+
else {
|
|
902
|
+
basemaps[Object.keys(basemaps)[0]].addTo(map);
|
|
903
|
+
}
|
|
904
|
+
if (showLayerMenu) {
|
|
905
|
+
map.removeControl(layercontrol);
|
|
906
|
+
layercontrol = L.control.layers(basemaps, overlays).addTo(map);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
895
909
|
}
|
|
896
|
-
var shape;
|
|
897
|
-
map.on('draw:created', function (e) {
|
|
898
|
-
var name = e.layerType + drawCount;
|
|
899
|
-
drawCount = drawCount + 1;
|
|
900
910
|
|
|
901
|
-
e.layer.on('contextmenu', function(e) {
|
|
902
|
-
L.DomEvent.stopPropagation(e);
|
|
903
|
-
var rmen = L.popup({offset:[0,-12]}).setLatLng(e.latlng);
|
|
904
|
-
rmen.setContent("<input type='text' autofocus value='"+e.target.name+"' id='dinput' placeholder='name (,icon, layer)'/><br/><button onclick='editPoly(\""+e.target.name+"\",true);'>Edit points</button><button onclick='delMarker(\""+e.target.name+"\",true);'>Delete</button><button onclick='sendDrawing();'>OK</button>");
|
|
905
|
-
map.openPopup(rmen);
|
|
906
|
-
});
|
|
907
911
|
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
912
|
+
// Now add the overlays
|
|
913
|
+
var addOverlays = function(overlist) {
|
|
914
|
+
//console.log("OVERLAYS",overlist)
|
|
915
|
+
// var overlookup = { DR:"Drawing", CO:"Countries", DN:"Day/Night", BU:"Buildings", SN:"Ship Navigaion", HM:"Heatmap", AC:"Air corridors", TL:"Place labels" };
|
|
916
|
+
// "DR,CO,DN,BU,SN,HM"
|
|
917
|
+
|
|
918
|
+
// Add the drawing layer...
|
|
919
|
+
if (overlist.indexOf("DR")!==-1) {
|
|
920
|
+
layers["_drawing"] = new L.FeatureGroup();
|
|
921
|
+
overlays["drawing"] = layers["_drawing"];
|
|
922
|
+
map.options.drawControlTooltips = false;
|
|
923
|
+
var drawCount = 0;
|
|
924
|
+
var drawControl = new L.Control.Draw({
|
|
925
|
+
draw: {
|
|
926
|
+
polyline: { shapeOptions: { clickable:true } },
|
|
927
|
+
marker: false,
|
|
928
|
+
//circle: false,
|
|
929
|
+
circle: { shapeOptions: { clickable:true } },
|
|
930
|
+
circlemarker: false,
|
|
931
|
+
rectangle: { shapeOptions: { clickable:true } },
|
|
932
|
+
polygon: { shapeOptions: { clickable:true } }
|
|
933
|
+
}
|
|
934
|
+
//edit: none
|
|
935
|
+
// {
|
|
936
|
+
// featureGroup: layers["_drawing"],
|
|
937
|
+
// remove: true,
|
|
938
|
+
// edit: true
|
|
939
|
+
// }
|
|
940
|
+
});
|
|
941
|
+
var changeDrawColour = function(col) {
|
|
942
|
+
drawControl.setDrawingOptions({
|
|
943
|
+
polyline: { shapeOptions: { color:col } },
|
|
944
|
+
circle: { shapeOptions: { color:col } },
|
|
945
|
+
rectangle: { shapeOptions: { color:col } },
|
|
946
|
+
polygon: { shapeOptions: { color:col } }
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
var shape;
|
|
950
|
+
map.on('draw:created', function (e) {
|
|
951
|
+
var name = e.layerType + drawCount;
|
|
952
|
+
drawCount = drawCount + 1;
|
|
922
953
|
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
954
|
+
e.layer.on('contextmenu', function(e) {
|
|
955
|
+
L.DomEvent.stopPropagation(e);
|
|
956
|
+
var rmen = L.popup({offset:[0,-12]}).setLatLng(e.latlng);
|
|
957
|
+
rmen.setContent("<input type='text' autofocus value='"+e.target.name+"' id='dinput' placeholder='name (,icon, layer)'/><br/><button onclick='editPoly(\""+e.target.name+"\",true);'>Edit points</button><button onclick='delMarker(\""+e.target.name+"\",true);'>Delete</button><button onclick='sendDrawing();'>OK</button>");
|
|
958
|
+
map.openPopup(rmen);
|
|
959
|
+
});
|
|
928
960
|
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
961
|
+
var la, lo, cent;
|
|
962
|
+
if (e.layer.hasOwnProperty("_latlng")) {
|
|
963
|
+
la = e.layer._latlng.lat;
|
|
964
|
+
lo = e.layer._latlng.lng;
|
|
965
|
+
cent = e.layer._latlng;
|
|
966
|
+
}
|
|
967
|
+
else {
|
|
968
|
+
cent = e.layer.getBounds().getCenter();
|
|
969
|
+
}
|
|
970
|
+
var m = {action:"draw", name:name, layer:"_drawing", options:e.layer.options, radius:e.layer._mRadius, lat:la, lon:lo};
|
|
971
|
+
if (e.layer.hasOwnProperty("_latlngs")) {
|
|
972
|
+
if (e.layer.options.fill === false) { m.line = e.layer._latlngs; }
|
|
973
|
+
else { m.area = e.layer._latlngs[0]; }
|
|
974
|
+
}
|
|
936
975
|
|
|
976
|
+
shape = {m:m, layer:e.layer};
|
|
977
|
+
polygons[name] = shape.layer;
|
|
978
|
+
polygons[name].lay = "_drawing";
|
|
979
|
+
polygons[name].name = name;
|
|
980
|
+
layers["_drawing"].addLayer(shape.layer);
|
|
937
981
|
|
|
938
|
-
var
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
};
|
|
982
|
+
var rightmenuMarker = L.popup({offset:[0,-12]}).setContent("<input type='text' autofocus value='"+name+"' id='dinput' placeholder='name (,icon, layer)'/><br/><button onclick='editPoly(\""+name+"\",true);'>Edit points</button><button onclick='delMarker(\""+name+"\",true);'>Delete</button><button onclick='sendDrawing(\""+name+"\");'>OK</button>");
|
|
983
|
+
if (e.layer.options.fill === false && navigator.onLine) {
|
|
984
|
+
rightmenuMarker = L.popup({offset:[0,-12]}).setContent("<input type='text' autofocus value='"+name+"' id='dinput' placeholder='name (,icon, layer)'/><br/><button onclick='editPoly(\""+name+"\",true);'>Edit points</button><button onclick='delMarker(\""+name+"\",true);'>Delete</button><button onclick='sendRoute(\""+name+"\");'>Route</button><button onclick='sendDrawing(\""+name+"\");'>OK</button>");
|
|
985
|
+
}
|
|
986
|
+
rightmenuMarker.setLatLng(cent);
|
|
987
|
+
setTimeout(function() {map.openPopup(rightmenuMarker)},25);
|
|
988
|
+
});
|
|
945
989
|
|
|
946
|
-
var
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
990
|
+
var sendDrawing = function(n) {
|
|
991
|
+
var thing = document.getElementById('dinput').value;
|
|
992
|
+
map.closePopup();
|
|
993
|
+
shape.m.name = thing;
|
|
994
|
+
delMarker(n,true);
|
|
995
|
+
|
|
996
|
+
polygons[thing] = shape.layer;
|
|
997
|
+
polygons[thing].lay = "_drawing";
|
|
998
|
+
polygons[thing].name = thing;
|
|
999
|
+
layers["_drawing"].addLayer(shape.layer);
|
|
1000
|
+
ws.send(JSON.stringify(shape.m));
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
var defaultOptions = function () {
|
|
1004
|
+
var options = {};
|
|
1005
|
+
options.precision = 5;
|
|
1006
|
+
options.factor = Math.pow(10, options.precision);
|
|
1007
|
+
options.dimension = 2;
|
|
1008
|
+
return options;
|
|
1009
|
+
};
|
|
1010
|
+
|
|
1011
|
+
var decode = function (encoded, options) {
|
|
1012
|
+
options = defaultOptions(options);
|
|
1013
|
+
var flatPoints = decodeDeltas(encoded);
|
|
1014
|
+
var points = [];
|
|
1015
|
+
for (var i = 0, len = flatPoints.length; i + (options.dimension - 1) < len;) {
|
|
1016
|
+
var point = [];
|
|
1017
|
+
for (var dim = 0; dim < options.dimension; ++dim) {
|
|
1018
|
+
point.push(flatPoints[i++]);
|
|
1019
|
+
}
|
|
1020
|
+
points.push(point);
|
|
1021
|
+
}
|
|
1022
|
+
return points;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
var decodeDeltas = function (encoded, options) {
|
|
1026
|
+
options = defaultOptions(options);
|
|
1027
|
+
var lastNumbers = [];
|
|
1028
|
+
var numbers = decodeFloats(encoded, options);
|
|
1029
|
+
for (var i = 0, len = numbers.length; i < len;) {
|
|
1030
|
+
for (var d = 0; d < options.dimension; ++d, ++i) {
|
|
1031
|
+
numbers[i] = Math.round((lastNumbers[d] = numbers[i] + (lastNumbers[d] || 0)) * options.factor) / options.factor;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
return numbers;
|
|
954
1035
|
}
|
|
955
|
-
points.push(point);
|
|
956
|
-
}
|
|
957
|
-
return points;
|
|
958
|
-
}
|
|
959
1036
|
|
|
960
|
-
var
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
1037
|
+
var decodeFloats = function (encoded, options) {
|
|
1038
|
+
options = defaultOptions(options);
|
|
1039
|
+
var numbers = decodeSignedIntegers(encoded);
|
|
1040
|
+
for (var i = 0, len = numbers.length; i < len; ++i) {
|
|
1041
|
+
numbers[i] /= options.factor;
|
|
1042
|
+
}
|
|
1043
|
+
return numbers;
|
|
967
1044
|
}
|
|
1045
|
+
|
|
1046
|
+
var decodeSignedIntegers = function (encoded) {
|
|
1047
|
+
var numbers = decodeUnsignedIntegers(encoded);
|
|
1048
|
+
for (var i = 0, len = numbers.length; i < len; ++i) {
|
|
1049
|
+
var num = numbers[i];
|
|
1050
|
+
numbers[i] = (num & 1) ? ~(num >> 1) : (num >> 1);
|
|
1051
|
+
}
|
|
1052
|
+
return numbers;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
var decodeUnsignedIntegers = function (encoded) {
|
|
1056
|
+
var numbers = [];
|
|
1057
|
+
var current = 0;
|
|
1058
|
+
var shift = 0;
|
|
1059
|
+
for (var i = 0, len = encoded.length; i < len; ++i) {
|
|
1060
|
+
var b = encoded.charCodeAt(i) - 63;
|
|
1061
|
+
current |= (b & 0x1f) << shift;
|
|
1062
|
+
if (b < 0x20) {
|
|
1063
|
+
numbers.push(current);
|
|
1064
|
+
current = 0;
|
|
1065
|
+
shift = 0;
|
|
1066
|
+
} else {
|
|
1067
|
+
shift += 5;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
return numbers;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
var sendRoute = function(n) {
|
|
1074
|
+
var p = (polygons[n]._latlngs.map(function(x) {
|
|
1075
|
+
return x.lng+","+x.lat;
|
|
1076
|
+
})).join(';');
|
|
1077
|
+
|
|
1078
|
+
fetch('https://router.project-osrm.org/route/v1/driving/'+p)
|
|
1079
|
+
.then(response => response.json())
|
|
1080
|
+
.then(data => {
|
|
1081
|
+
if (data.code !== "Ok") { sendDrawing(n); }
|
|
1082
|
+
var r = decode(data.routes[0].geometry).map( x => L.latLng(x[0],x[1]) );
|
|
1083
|
+
polygons[n]._latlngs = r;
|
|
1084
|
+
shape.m.line = r;
|
|
1085
|
+
sendDrawing(n);
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
|
|
968
1089
|
}
|
|
969
|
-
return numbers;
|
|
970
|
-
}
|
|
971
1090
|
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1091
|
+
// Add the countries (world-110m) for offline use
|
|
1092
|
+
if (overlist.indexOf("CO")!==-1 || (!navigator.onLine)) {
|
|
1093
|
+
var customTopoLayer = L.geoJson(null, {clickable:false, style: {color:"blue", weight:2, fillColor:"#cf6", fillOpacity:0.04}});
|
|
1094
|
+
layers["_countries"] = omnivore.topojson('images/world-50m-flat.json',null,customTopoLayer);
|
|
1095
|
+
overlays["countries"] = layers["_countries"];
|
|
977
1096
|
}
|
|
978
|
-
return numbers;
|
|
979
|
-
}
|
|
980
1097
|
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
numbers[i] = (num & 1) ? ~(num >> 1) : (num >> 1);
|
|
1098
|
+
// Add the day/night overlay
|
|
1099
|
+
if (overlist.indexOf("DN")!==-1) {
|
|
1100
|
+
layers["_daynight"] = new L.LayerGroup();
|
|
1101
|
+
overlays["day/night"] = layers["_daynight"];
|
|
986
1102
|
}
|
|
987
|
-
return numbers;
|
|
988
|
-
}
|
|
989
1103
|
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
current = 0;
|
|
1000
|
-
shift = 0;
|
|
1001
|
-
} else {
|
|
1002
|
-
shift += 5;
|
|
1104
|
+
// Add live rain data
|
|
1105
|
+
if (overlist.indexOf("RA")!==-1) {
|
|
1106
|
+
if (navigator.onLine) {
|
|
1107
|
+
overlays["rainfall"] = new L.TileLayer('https://tilecache.rainviewer.com/v2/radar/' + parseInt(Date.now()/600000)*600 + '/256/{z}/{x}/{y}/2/1_1.png', {
|
|
1108
|
+
tileSize: 256,
|
|
1109
|
+
opacity: 0.4,
|
|
1110
|
+
transparent: true,
|
|
1111
|
+
attribution: '<a href="https://rainviewer.com" target="_blank">rainviewer.com</a>'
|
|
1112
|
+
});
|
|
1003
1113
|
}
|
|
1004
1114
|
}
|
|
1005
|
-
return numbers;
|
|
1006
|
-
}
|
|
1007
1115
|
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
fetch('https://router.project-osrm.org/route/v1/driving/'+p)
|
|
1014
|
-
.then(response => response.json())
|
|
1015
|
-
.then(data => {
|
|
1016
|
-
if (data.code !== "Ok") { sendDrawing(n); }
|
|
1017
|
-
var r = decode(data.routes[0].geometry).map( x => L.latLng(x[0],x[1]) );
|
|
1018
|
-
polygons[n]._latlngs = r;
|
|
1019
|
-
shape.m.line = r;
|
|
1020
|
-
sendDrawing(n);
|
|
1021
|
-
});
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
var sendDrawing = function(n) {
|
|
1025
|
-
var thing = document.getElementById('dinput').value;
|
|
1026
|
-
map.closePopup();
|
|
1027
|
-
shape.m.name = thing;
|
|
1028
|
-
delMarker(n,true);
|
|
1029
|
-
|
|
1030
|
-
polygons[thing] = shape.layer;
|
|
1031
|
-
polygons[thing].lay = "_drawing";
|
|
1032
|
-
polygons[thing].name = thing;
|
|
1033
|
-
layers["_drawing"].addLayer(shape.layer);
|
|
1034
|
-
ws.send(JSON.stringify(shape.m));
|
|
1035
|
-
}
|
|
1116
|
+
// Add the buildings layer
|
|
1117
|
+
if (overlist.indexOf("BU")!==-1) {
|
|
1118
|
+
overlays["buildings"] = new OSMBuildings(map).load();
|
|
1119
|
+
// map.removeLayer(overlays["buildings"]); // Hide it at start
|
|
1120
|
+
}
|
|
1036
1121
|
|
|
1037
|
-
// Add
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
overlays["
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
// Add live rain data
|
|
1047
|
-
if (navigator.onLine) {
|
|
1048
|
-
overlays["rainfall"] = new L.TileLayer('https://tilecache.rainviewer.com/v2/radar/' + parseInt(Date.now()/600000)*600 + '/256/{z}/{x}/{y}/2/1_1.png', {
|
|
1049
|
-
tileSize: 256,
|
|
1050
|
-
opacity: 0.4,
|
|
1051
|
-
transparent: true,
|
|
1052
|
-
attribution: '<a href="https://rainviewer.com" target="_blank">rainviewer.com</a>'
|
|
1053
|
-
});
|
|
1122
|
+
// Add Railways
|
|
1123
|
+
if (overlist.indexOf("RW")!==-1) {
|
|
1124
|
+
// eg https://a.tiles.openrailwaymap.org/standard/11/1015/686.png
|
|
1125
|
+
overlays["railways"] = L.tileLayer('https://{s}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png', {
|
|
1126
|
+
maxZoom: 19,
|
|
1127
|
+
attribution: 'Map data: © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> | Map style: © <a href="https://www.OpenRailwayMap.org">OpenRailwayMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)'
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1054
1130
|
|
|
1055
|
-
// Add
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
// maxZoom: 19,
|
|
1069
|
-
// attribution: 'Map data: © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> | Map style: © <a href="https://www.OpenRailwayMap.org">OpenRailwayMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)'
|
|
1070
|
-
// });
|
|
1071
|
-
|
|
1072
|
-
// // Add Public Transport (Buses)
|
|
1073
|
-
// overlays["public transport"] = L.tileLayer('https://openptmap.org/tiles/{z}/{x}/{y}.png', {
|
|
1074
|
-
// maxZoom: 17,
|
|
1075
|
-
// attribution: 'Map data: © <a href="https://www.openptmap.org">OpenPtMap</a> contributors'
|
|
1076
|
-
// });
|
|
1131
|
+
// Add Air Corridors
|
|
1132
|
+
if (overlist.indexOf("AC")!==-1) {
|
|
1133
|
+
overlays["air corridors"] = L.tileLayer('https://{s}.tile.maps.openaip.net/geowebcache/service/tms/1.0.0/openaip_basemap@EPSG%3A900913@png/{z}/{x}/{y}.{ext}', {
|
|
1134
|
+
attribution: '<a href="https://www.openaip.net/">openAIP Data</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-NC-SA</a>)',
|
|
1135
|
+
ext: 'png',
|
|
1136
|
+
minZoom: 4,
|
|
1137
|
+
maxZoom: 15,
|
|
1138
|
+
maxNativeZoom: 14,
|
|
1139
|
+
tms: true,
|
|
1140
|
+
detectRetina: true,
|
|
1141
|
+
subdomains: '12'
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1077
1144
|
|
|
1078
1145
|
// Add the OpenSea markers layer
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
}
|
|
1146
|
+
if (overlist.indexOf("SN")!==-1) {
|
|
1147
|
+
overlays["ship nav"] = L.tileLayer('https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png', {
|
|
1148
|
+
maxZoom: 19,
|
|
1149
|
+
attribution: 'Map data: © <a href="https://www.openseamap.org">OpenSeaMap</a> contributors'
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1084
1152
|
|
|
1085
|
-
// Add the
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1153
|
+
// Add the Stamen Toner Labels layer
|
|
1154
|
+
if (overlist.indexOf("TL")!==-1) {
|
|
1155
|
+
overlays["place labels"] = L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-labels/{z}/{x}/{y}{r}.{ext}', {
|
|
1156
|
+
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
|
1157
|
+
subdomains: 'abcd',
|
|
1158
|
+
minZoom: 0,
|
|
1159
|
+
maxZoom: 20,
|
|
1160
|
+
ext: 'png'
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1089
1163
|
|
|
1090
|
-
|
|
1091
|
-
if (
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1164
|
+
// Add the heatmap layer
|
|
1165
|
+
if (overlist.indexOf("HM")!==-1) {
|
|
1166
|
+
heat = L.heatLayer([], {radius:60, gradient:{0.2:'blue', 0.4:'lime', 0.6:'red', 0.8:'yellow', 1:'white'}});
|
|
1167
|
+
layers["_heat"] = new L.LayerGroup().addLayer(heat);
|
|
1168
|
+
overlays["heatmap"] = layers["_heat"];
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
if (showLayerMenu) {
|
|
1172
|
+
map.removeControl(layercontrol);
|
|
1173
|
+
layercontrol = L.control.layers(basemaps, overlays).addTo(map);
|
|
1095
1174
|
}
|
|
1096
1175
|
}
|
|
1097
|
-
if (navigator.onLine) { basemaps[baselayername].addTo(map); }
|
|
1098
1176
|
|
|
1099
1177
|
// Layer control based on select box rather than radio buttons.
|
|
1100
1178
|
//var layercontrol = L.control.selectLayers(basemaps, overlays).addTo(map);
|
|
1101
|
-
layercontrol = L.control.layers(basemaps, overlays);
|
|
1179
|
+
var layercontrol = L.control.layers(basemaps, overlays);
|
|
1102
1180
|
|
|
1103
1181
|
// Add the layers control widget
|
|
1104
1182
|
if (!inIframe) { layercontrol.addTo(map); }
|
|
@@ -1891,7 +1969,7 @@ function setMarker(data) {
|
|
|
1891
1969
|
fb.action = "click";
|
|
1892
1970
|
ws.send(JSON.stringify(fb));
|
|
1893
1971
|
});
|
|
1894
|
-
if ((data.addtoheatmap !== "false") || (!data.hasOwnProperty("addtoheatmap"))) { // Added to give ability to control if points from active layer contribute to heatmap
|
|
1972
|
+
if (heat && ((data.addtoheatmap !== "false") || (!data.hasOwnProperty("addtoheatmap")))) { // Added to give ability to control if points from active layer contribute to heatmap
|
|
1895
1973
|
if (heatAll || map.hasLayer(layers[lay])) { heat.addLatLng(lli); }
|
|
1896
1974
|
}
|
|
1897
1975
|
markers[data.name] = marker;
|
|
@@ -1962,7 +2040,13 @@ function setMarker(data) {
|
|
|
1962
2040
|
|
|
1963
2041
|
// handle any incoming COMMANDS to control the map remotely
|
|
1964
2042
|
function doCommand(cmd) {
|
|
1965
|
-
//console.log("COMMAND",cmd);
|
|
2043
|
+
// console.log("COMMAND",cmd);
|
|
2044
|
+
if (cmd.init && cmd.hasOwnProperty("maplist")) {
|
|
2045
|
+
addBaseMaps(cmd.maplist,cmd.layer);
|
|
2046
|
+
}
|
|
2047
|
+
if (cmd.init && cmd.hasOwnProperty("overlist")) {
|
|
2048
|
+
addOverlays(cmd.overlist);
|
|
2049
|
+
}
|
|
1966
2050
|
if (cmd.hasOwnProperty("toptitle")) {
|
|
1967
2051
|
if (!inIframe ) {
|
|
1968
2052
|
document.title = cmd.toptitle;
|
|
@@ -2089,7 +2173,7 @@ function doCommand(cmd) {
|
|
|
2089
2173
|
|
|
2090
2174
|
var existsalready = false;
|
|
2091
2175
|
// Add a new base map layer
|
|
2092
|
-
if (cmd.map && cmd.map.hasOwnProperty("name") && cmd.map.hasOwnProperty("url") && cmd.map.hasOwnProperty("opt")) {
|
|
2176
|
+
if (cmd.map && cmd.map.hasOwnProperty("name") && cmd.map.name.length>0 && cmd.map.hasOwnProperty("url") && cmd.map.hasOwnProperty("opt")) {
|
|
2093
2177
|
console.log("BASE",cmd.map);
|
|
2094
2178
|
if (basemaps.hasOwnProperty(cmd.map.name)) { existsalready = true; }
|
|
2095
2179
|
if (cmd.map.hasOwnProperty("wms")) { // special case for wms
|