{let r=e*(360/t);return Math.log2(r/256)},pi=class{constructor(e){let r=e.dark?Se:Le;this.paint_rules=e.paint_rules||Ce(r,e.shade),this.label_rules=e.label_rules||Te(r,e.shade,e.language1,e.language2),this.backgroundColor=e.backgroundColor,this.views=Ve(e),this.debug=e.debug||"",this.xray=e.xray}drawContext(e,r,i,n,a){return O(this,null,function*(){let s=mi(n),l=new he.default((s.x+H)/(H*2),1-(s.y+H)/(H*2)).clone().mult(Math.pow(2,a)*256).sub(new he.default(r/2,i/2)),u={minX:l.x,minY:l.y,maxX:l.x+r,maxY:l.y+i},f=[];for(let[p,b]of this.views){let y=b.getBbox(a,u);f.push({key:p,promise:y})}let d=yield Promise.all(f.map(p=>p.promise.then(b=>({status:"fulfilled",value:b,key:p.key}),b=>({status:"rejected",value:[],reason:b,key:p.key})))),c=new Map;for(let p of d)p.status==="fulfilled"&&c.set(p.key,p.value);let x=performance.now(),w=new Ue(a,e,this.label_rules,16,void 0),z=w.add(c);this.backgroundColor&&(e.save(),e.fillStyle=this.backgroundColor,e.fillRect(0,0,r,i),e.restore());let h=this.paint_rules;this.xray&&(h=ut(c,this.xray));let m=Ye(e,a,c,this.xray?null:w.index,h,u,l,!0,this.debug);if(this.debug){e.save(),e.translate(-l.x,-l.y),e.strokeStyle=this.debug,e.fillStyle=this.debug,e.font="12px sans-serif";let p=0;for(let[b,y]of c){for(let g of y){e.strokeRect(g.origin.x,g.origin.y,g.dim,g.dim);let v=g.data_tile;e.fillText(b+(b?" ":"")+v.z+" "+v.x+" "+v.y,g.origin.x+4,g.origin.y+14*(1+p))}p++}e.restore()}return{elapsed:performance.now()-x,project:ia(l,a),unproject:na(l,a)}})}drawCanvas(a,s,o){return O(this,arguments,function*(e,r,i,n={}){let l=window.devicePixelRatio,u=e.clientWidth,f=e.clientHeight;e.width==u*l&&e.height==f*l||(e.width=u*l,e.height=f*l),n.lang&&(e.lang=n.lang);let d=e.getContext("2d");return d.setTransform(l,0,0,l,0,0),this.drawContext(d,u,f,r,i)})}drawContextBounds(e,r,i,n,a){return O(this,null,function*(){let s=i.x-r.x,o=new he.default((r.x+i.x)/2,(r.y+i.y)/2);return this.drawContext(e,n,a,o,Vt(s,n))})}drawCanvasBounds(s,o,l,u){return O(this,arguments,function*(e,r,i,n,a={}){let f=i.x-r.x,d=new he.default((r.x+i.x)/2,(r.y+i.y)/2);return this.drawCanvas(e,d,Vt(f,n),a)})}};var yi=N(re());var aa=t=>new Promise((e,r)=>{setTimeout(()=>{e()},t)}),sa=t=>t.then(e=>({status:"fulfilled",value:e}),e=>({status:"rejected",reason:e})),oa=(t={})=>{class e extends L.GridLayer{constructor(i={}){i.noWrap&&!i.bounds&&(i.bounds=[[-90,-180],[90,180]]),i.attribution==null&&(i.attribution='Protomaps \xA9 OpenStreetMap'),super(i);let n=i.dark?Se:Le;this.paint_rules=i.paint_rules||Ce(n,i.shade),this.label_rules=i.label_rules||Te(n,i.shade,i.language1,i.language2),this.backgroundColor=i.backgroundColor,this.lastRequestedZ=void 0,this.xray=i.xray,this.tasks=i.tasks||[],this.views=Ve(i),this.debug=i.debug;let a=document.createElement("canvas").getContext("2d");this.scratch=a,this.onTilesInvalidated=s=>{s.forEach(o=>{this.rerenderTile(o)})},this.labelers=new je(this.scratch,this.label_rules,16,this.onTilesInvalidated),this.tile_size=256*window.devicePixelRatio,this.tileDelay=i.tileDelay||3,this.lang=i.lang,this.inspector=this.inspect(this)}setDefaultStyle(i,n,a,s){let o=i?Se:Le;this.paint_rules=Ce(o,n),this.label_rules=Te(o,n,a,s)}renderTile(i,n,a,s=()=>{}){return O(this,null,function*(){this.lastRequestedZ=i.z;let o=[];for(let[_,k]of this.views){let S=k.getDisplayTile(i);o.push({key:_,promise:S})}let l=yield Promise.all(o.map(_=>_.promise.then(k=>({status:"fulfilled",value:k,key:_.key}),k=>({status:"rejected",reason:k,key:_.key})))),u=new Map;for(let _ of l)_.status==="fulfilled"?u.set(_.key,[_.value]):_.reason.name==="AbortError"||console.error(_.reason);if(n.key!=a||this.lastRequestedZ!==i.z||(yield Promise.all(this.tasks.map(sa)),n.key!=a)||this.lastRequestedZ!==i.z)return;let f=this.labelers.add(i.z,u);if(n.key!=a||this.lastRequestedZ!==i.z)return;let d=this.labelers.getIndex(i.z);if(!this._map)return;let c=this._map.getCenter().wrap(),x=this._getTiledPixelBounds(c),w=this._pxBoundsToTileRange(x),z=w.getCenter(),h=i.distanceTo(z)*this.tileDelay;if(yield aa(h),n.key!=a||this.lastRequestedZ!==i.z)return;let m=16,p={minX:256*i.x-m,minY:256*i.y-m,maxX:256*(i.x+1)+m,maxY:256*(i.y+1)+m},b=new yi.default(256*i.x,256*i.y);n.width=this.tile_size,n.height=this.tile_size;let y=n.getContext("2d");y.setTransform(this.tile_size/256,0,0,this.tile_size/256,0,0),y.clearRect(0,0,256,256),this.backgroundColor&&(y.save(),y.fillStyle=this.backgroundColor,y.fillRect(0,0,256,256),y.restore());var g=0;let v=this.paint_rules;if(this.xray&&(v=ut(u,this.xray)),g=Ye(y,i.z,u,this.xray?null:d,v,p,b,!1,this.debug),this.debug){y.save(),y.fillStyle=this.debug,y.font="600 12px sans-serif",y.fillText(i.z+" "+i.x+" "+i.y,4,14),y.font="12px sans-serif";let _=28;for(let[k,S]of u){let D=S[0].data_tile;y.fillText(k+(k?" ":"")+D.z+" "+D.x+" "+D.y,4,_),_+=14}y.font="600 10px sans-serif",g>8&&(y.fillText(g.toFixed()+" ms paint",4,_),_+=14),f>8&&y.fillText(f.toFixed()+" ms layout",4,_),y.strokeStyle=this.debug,y.lineWidth=.5,y.beginPath(),y.moveTo(0,0),y.lineTo(0,256),y.stroke(),y.lineWidth=.5,y.beginPath(),y.moveTo(0,0),y.lineTo(256,0),y.stroke(),y.restore()}s()})}rerenderTile(i){for(let n in this._tiles){let a=this._wrapCoords(this._keyToTileCoords(n));i===this._tileCoordsToKey(a)&&this.renderTile(a,this._tiles[n].el,i)}}clearLayout(){this.labelers=new je(this.scratch,this.label_rules,16,this.onTilesInvalidated)}rerenderTiles(){for(let i in this._tiles){let n=this._wrapCoords(this._keyToTileCoords(i)),a=this._tileCoordsToKey(n);this.renderTile(n,this._tiles[i].el,a)}}createTile(i,n){let a=L.DomUtil.create("canvas","leaflet-tile");a.lang=this.lang;let s=this._tileCoordsToKey(i);return a.key=s,this.renderTile(i,a,s,()=>{n(null,a)}),a}_removeTile(i){let n=this._tiles[i];!n||(n.el.removed=!0,n.el.key=void 0,L.DomUtil.removeClass(n.el,"leaflet-tile-loaded"),n.el.width=n.el.height=0,L.DomUtil.remove(n.el),delete this._tiles[i],this.fire("tileunload",{tile:n.el,coords:this._keyToTileCoords(i)}))}queryFeatures(i,n){let a=new Map;for(var[s,o]of this.views)a.set(s,o.queryFeatures(i,n,this._map.getZoom()));return a}inspect(i){return n=>{let a=["\u25CE","\u27CD","\u25FB"],s=i._map.wrapLatLng(n.latlng),o=i.queryFeatures(s.lng,s.lat);var l="";let u=!0;for(var[f,d]of o)for(var c of d)if(!(this.xray&&this.xray!==!0&&!((this.xray.dataSource||"")===f&&this.xray.dataLayer===c.layerName))){l=l+`${a[c.feature.geomType-1]} ${f} ${f?"/":""} ${c.layerName} ${c.feature.id||""}
`;for(let x in c.feature.props)l=l+`${x} = ${c.feature.props[x]}
`;u=!1}u&&(l="No features."),L.popup().setLatLng(n.latlng).setContent(''+l+"
").openOn(i._map)}}addInspector(i){return i.on("click",this.inspector)}removeInspector(i){return i.off("click",this.inspector)}}return new e(t)};function Yt(t){let e=0,r=0;for(let o of t)e+=o.w*o.h,r=Math.max(r,o.w);t.sort((o,l)=>l.h-o.h);let i=Math.max(Math.ceil(Math.sqrt(e/.95)),r),n=[{x:0,y:0,w:i,h:1/0}],a=0,s=0;for(let o of t)for(let l=n.length-1;l>=0;l--){let u=n[l];if(!(o.w>u.w||o.h>u.h)){if(o.x=u.x,o.y=u.y,s=Math.max(s,o.y+o.h),a=Math.max(a,o.x+o.w),o.w===u.w&&o.h===u.h){let f=n.pop();l{let i=new FontFace(t,"url("+e+")",{weight:r});return document.fonts.add(i),i.load()},xi=t=>O(void 0,null,function*(){return new Promise((e,r)=>{let i=new Image;i.onload=()=>e(i),i.onerror=()=>r("Invalid SVG"),i.src=t})}),la=`
+
+`,gi=class{constructor(e){this.src=e,this.canvas=document.createElement("canvas"),this.mapping=new Map,this.missingBox={x:0,y:0,w:0,h:0}}load(){return O(this,null,function*(){let e=this.src,r=window.devicePixelRatio;e.endsWith(".html")&&(e=yield(yield fetch(e)).text());let i=new window.DOMParser().parseFromString(e,"text/html"),n=Array.from(i.body.children),a=yield xi("data:image/svg+xml;base64,"+btoa(la)),s=[{w:a.width*r,h:a.height*r,img:a,id:""}],o=new XMLSerializer;for(let c of n){var l=btoa(o.serializeToString(c)),u="data:image/svg+xml;base64,"+l;let x=yield xi(u);s.push({w:x.width*r,h:x.height*r,img:x,id:c.id})}let f=Yt(s);this.canvas.width=f.w,this.canvas.height=f.h;let d=this.canvas.getContext("2d");if(d)for(let c of s)c.x!==void 0&&c.y!==void 0&&(d.drawImage(c.img,c.x,c.y,c.w,c.h),c.id?this.mapping.set(c.id,{x:c.x,y:c.y,w:c.w,h:c.h}):this.missingBox={x:c.x,y:c.y,w:c.w,h:c.h});return this})}get(e){let r=this.mapping.get(e);return r||(r=this.missingBox),r}};function ht(t,e){return typeof t=="number"?t:e}function Je(t){if(t.includes("$type"))return e=>!0;if(t[0]=="==")return(e,r)=>r.props[t[1]]===t[2];if(t[0]=="!=")return(e,r)=>r.props[t[1]]!==t[2];if(t[0]=="!"){let e=Je(t[1]);return(r,i)=>!e(r,i)}else{if(t[0]==="<")return(e,r)=>ht(r.props[t[1]],1/0)ht(r.props[t[1]],1/0)<=t[2];if(t[0]===">")return(e,r)=>ht(r.props[t[1]],-1/0)>t[2];if(t[0]===">=")return(e,r)=>ht(r.props[t[1]],-1/0)>=t[2];if(t[0]==="in")return(e,r)=>t.slice(2,t.length).includes(r.props[t[1]]);if(t[0]==="!in")return(e,r)=>!t.slice(2,t.length).includes(r.props[t[1]]);if(t[0]==="has")return(e,r)=>r.props.hasOwnProperty(t[1]);if(t[0]==="!has")return(e,r)=>!r.props.hasOwnProperty(t[1]);if(t[0]==="all"){let e=t.slice(1,t.length).map(r=>Je(r));return(r,i)=>e.every(n=>n(r,i))}else if(t[0]==="any"){let e=t.slice(1,t.length).map(r=>Je(r));return(r,i)=>e.some(n=>n(r,i))}else return console.log("Unimplemented filter: ",t[0]),e=>!1}}function ft(t){if(t.base&&t.stops)return r=>j(t.base,t.stops)(r-1);if(t[0]=="interpolate"&&t[1][0]=="exponential"&&t[2]=="zoom"){let r=t.slice(3),i=[];for(var e=0;ej(t[1][1],i)(n-1)}else if(t[0]=="step"&&t[1][0]=="get"){let r=t.slice(2),i=t[1][1];return(n,a)=>{let s=a==null?void 0:a.props[i];if(typeof s=="number"){if(s1}function jt(t,e=0){return t?typeof t=="number"?t:(r,i)=>i?ft(t)(r,i):e:e}function Nt(t,e){let r=jt(t,1),i=jt(e);return(n,a)=>{let s=typeof r=="number"?r:r(n,a);return i?s+(typeof i=="number"?i:i(n,a)):s}}function qt(t,e){let r=[];for(let o of t["text-font"])e.hasOwnProperty(o)&&r.push(e[o]);r.length===0&&r.push({face:"sans-serif"});let i=t["text-size"];var n="";r.length&&r[0].weight&&(n=r[0].weight+" ");var a="";if(r.length&&r[0].style&&(a=r[0].style+" "),typeof i=="number")return o=>`${a}${n}${i}px ${r.map(l=>l.face).join(", ")}`;if(i.stops){var s=1.4;i.base?s=i.base:i.base=s;let o=ft(i);return(l,u)=>`${a}${n}${o(l,u)}px ${r.map(f=>f.face).join(", ")}`}else if(i[0]=="step"){let o=ft(i);return(l,u)=>`${a}${n}${o(l,u)}px ${r.map(f=>f.face).join(", ")}`}else return console.log("Can't parse font: ",t),o=>"12px sans-serif"}function ua(t,e){let r=[],i=[],n=new Map;for(var a of t.layers){if(n.set(a.id,a),a.layout&&a.layout.visibility=="none")continue;if(a.ref){let u=n.get(a.ref);a.type=u.type,a.filter=u.filter,a.source=u.source,a["source-layer"]=u["source-layer"]}let l=a["source-layer"];var s,o=void 0;a.filter&&(o=Je(a.filter)),a.type=="fill"?r.push({dataLayer:a["source-layer"],filter:o,symbolizer:new A({fill:a.paint["fill-color"],opacity:a.paint["fill-opacity"]})}):a.type=="fill-extrusion"?r.push({dataLayer:a["source-layer"],filter:o,symbolizer:new A({fill:a.paint["fill-extrusion-color"],opacity:a.paint["fill-extrusion-opacity"]})}):a.type=="line"?a.paint["line-dasharray"]?r.push({dataLayer:a["source-layer"],filter:o,symbolizer:new C({width:Nt(a.paint["line-width"],a.paint["line-gap-width"]),dash:a.paint["line-dasharray"],dashColor:a.paint["line-color"]})}):r.push({dataLayer:a["source-layer"],filter:o,symbolizer:new C({color:a.paint["line-color"],width:Nt(a.paint["line-width"],a.paint["line-gap-width"])})}):a.type=="symbol"?a.layout["symbol-placement"]=="line"?i.push({dataLayer:a["source-layer"],filter:o,symbolizer:new ce({font:qt(a.layout,e),fill:a.paint["text-color"],width:a.paint["text-halo-width"],stroke:a.paint["text-halo-color"],textTransform:a.layout["text-transform"],label_props:a.layout["text-field"]?[a.layout["text-field"]]:void 0})}):i.push({dataLayer:a["source-layer"],filter:o,symbolizer:new U({font:qt(a.layout,e),fill:a.paint["text-color"],stroke:a.paint["text-halo-color"],width:a.paint["text-halo-width"],textTransform:a.layout["text-transform"],label_props:a.layout["text-field"]?[a.layout["text-field"]]:void 0})}):a.type=="circle"&&r.push({dataLayer:a["source-layer"],filter:o,symbolizer:new te({radius:a.paint["circle-radius"],fill:a.paint["circle-color"],stroke:a.paint["circle-stroke-color"],width:a.paint["circle-stroke-width"]})})}return i.reverse(),{paint_rules:r,label_rules:i,tasks:[]}}var ha=t=>{let e=Ot(4,4,s=>{var o=s.getContext("2d");o&&(o.beginPath(),o.rect(0,0,1,1),o.rect(2,2,1,1),o.fillStyle="black",o.fill())});var r="black";t==="lite"&&(r="#d9d9d9");let i=["name:en","name"],n=[{dataLayer:"earth",symbolizer:new A({fill:"white"})},{dataLayer:"landuse",symbolizer:new A({pattern:e}),filter:(s,o)=>o.props.leisure=="park"},{dataLayer:"water",symbolizer:new A({fill:r})},{dataLayer:"roads",symbolizer:new C({color:"#dddddd"}),filter:(s,o)=>o.props["pmap:kind"]==="minor_road"},{dataLayer:"roads",symbolizer:new C({color:"white",width:de(16,[7,9,17,20])}),filter:(s,o)=>o.props["pmap:kind"]==="medium_road"},{dataLayer:"roads",symbolizer:new C({color:"#cccccc",width:de(10,[.2,.2,.2,.4,.8,1.5,4,7,13,16])}),filter:(s,o)=>o.props["pmap:kind"]==="medium_road"},{dataLayer:"roads",symbolizer:new C({color:"white",width:de(11,[1.25,5,5,5,8,11,18,22,30])}),filter:(s,o)=>o.props["pmap:kind"]==="major_road"},{dataLayer:"roads",symbolizer:new C({color:"black",width:de(9,[.15,.5,.7,1,1.5,1.9,5,7,12,18,26])}),filter:(s,o)=>o.props["pmap:kind"]==="major_road"},{dataLayer:"roads",symbolizer:new C({color:"white",width:de(7,[2.25,3.25,4.25,5,6,7,8,9,11,14,24,42,49])}),filter:(s,o)=>o.props["pmap:kind"]==="highway"},{dataLayer:"roads",symbolizer:new C({color:"black",width:de(6,[.1,1.5,1.5,1.5,2,2.5,3,3,4,6,9,15,28,35])}),filter:(s,o)=>o.props["pmap:kind"]==="highway"},{dataLayer:"transit",symbolizer:new C({color:"#888888",dashColor:"#888888",dash:[1,4],dashWidth:3}),filter:(s,o)=>o.props["pmap:kind"]==="railway",minzoom:14},{dataLayer:"transit",symbolizer:new C({color:"#888888"}),filter:(s,o)=>o.props["pmap:kind"]==="railway",minzoom:14},{dataLayer:"buildings",symbolizer:new C({color:"#888888",width:.5})},{dataLayer:"boundaries",symbolizer:new C({color:"black",width:1}),maxzoom:6},{dataLayer:"boundaries",symbolizer:new C({color:"white",width:2.5,dash:[3,1],dashWidth:.3,dashColor:"black"}),minzoom:7}],a=[{dataLayer:"places",symbolizer:new U({label_props:i,fill:"black",stroke:"white",width:1.5,fontFamily:"Inter",fontWeight:300,fontSize:15,justify:X.Center}),filter:(s,o)=>o.props["pmap:kind"]=="country"},{dataLayer:"places",symbolizer:new U({label_props:i,fill:"black",stroke:"white",width:2,fontFamily:"Inter",fontWeight:300,fontSize:12,justify:X.Center}),filter:(s,o)=>o.props["pmap:kind"]=="state"},{dataLayer:"places",symbolizer:new ye([new te({radius:2,fill:"black",stroke:"white",width:2}),new le({label_props:i,offsetX:3,fill:"black",stroke:"white",width:1.5,fontFamily:"Inter",fontWeight:600,fontSize:(s,o)=>o.props["pmap:rank"]==1?15:13})]),sort:(s,o)=>s["pmap:rank"]-o["pmap:rank"],filter:(s,o)=>o.props["pmap:kind"]=="city",maxzoom:8},{dataLayer:"places",symbolizer:new U({label_props:i,justify:X.Center,fill:"black",stroke:"white",width:2,fontFamily:"Inter",fontWeight:600,fontSize:(s,o)=>o.props["pmap:rank"]==1?15:13}),sort:(s,o)=>s["pmap:rank"]-o["pmap:rank"],filter:(s,o)=>o.props["pmap:kind"]=="city",minzoom:9},{dataLayer:"water",symbolizer:new ue({label_props:i,fill:"white",stroke:"black",width:3,font:"italic 400 12px Inter"})},{dataLayer:"landuse",symbolizer:new ue({fill:"black",stroke:"white",width:2,font:"italic 400 12px Inter"})},{dataLayer:"physical_point",symbolizer:new U({label_props:i,fill:"white",stroke:"black",width:3,font:"italic 600 12px Inter",textTransform:"uppercase",justify:X.Center}),filter:(s,o)=>["ocean","sea"].includes(o.props.place)},{dataLayer:"roads",symbolizer:new ce({fill:"black",stroke:"white",width:2,font:"600 14px Inter",offset:4})}];return{tasks:[Ut("Inter","https://cdn.protomaps.com/fonts/woff2/Inter.var.woff2","100 900")],paint_rules:n,label_rules:a,attribution:'Map tiles by Stamen Design, under CC BY 3.0.'}};return fa;})();
+/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */
diff --git a/worldmap/worldmap.js b/worldmap/worldmap.js
index 11a6529..a8d789c 100644
--- a/worldmap/worldmap.js
+++ b/worldmap/worldmap.js
@@ -38,6 +38,7 @@ var sendRoute;
var oldBounds = {ne:{lat:0, lng:0}, sw:{lat:0, lng:0}};
var edgeLayer = new L.layerGroup();
var edgeEnabled = true;
+var pmtloaded = "";
var iconSz = {
"Team/Crew": 24,
@@ -93,7 +94,7 @@ var connect = function() {
document.getElementById("footer").innerHTML = ""+pagefoot+"";
}
ws.send(JSON.stringify({action:"connected",parameters:Object.fromEntries((new URL(location)).searchParams),clientTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone || false}));
- onoffline();
+ setTimeout(function() { onoffline(); }, 500);
};
ws.onclose = function() {
console.log("DISCONNECTED");
@@ -181,7 +182,8 @@ layers["_countries"] = omnivore.topojson('images/world-50m-flat.json',null,custo
overlays["countries"] = layers["_countries"];
var onoffline = function() { if (!navigator.onLine) {
- map.addLayer(overlays["countries"]);
+ if (pmtloaded !== "") { basemaps[pmtloaded].addTo(map); layercontrol._update(); }
+ else { map.addLayer(overlays["countries"]); }
} }
document.addEventListener ("keydown", function (ev) {
@@ -581,7 +583,7 @@ setInterval( function() { moveTerminator() }, 60000 );
// move the rainfall overlay (if enabled) every 10 minutes
function moveRainfall() {
- if (navigator.onLine && map.hasLayer(overlays["rainfall"])) {
+ if (navigator.onLine && overlays.hasOwnProperty("rainfall") && map.hasLayer(overlays["rainfall"])) {
overlays["rainfall"]["_url"] = 'https://tilecache.rainviewer.com/v2/radar/' + parseInt(Date.now()/600000)*600 + '/256/{z}/{x}/{y}/2/1_1.png';
overlays["rainfall"].redraw();
}
@@ -1081,12 +1083,13 @@ var addBaseMaps = function(maplist,first) {
if (first) {
if (layerlookup[first]) { baselayername = layerlookup[first]; }
- else { basenayername = first; }
+ else { baselayername = first; }
+ if (!basemaps[baselayername]) { baselayername = Object.keys(basemaps)[0]; }
}
else {
- basenayername = Object.keys(basemaps)[0];
+ baselayername = Object.keys(basemaps)[0];
}
- basemaps[baselayername].addTo(map);
+ if (baselayername) { basemaps[baselayername].addTo(map); }
if (showLayerMenu) {
map.removeControl(layercontrol);
layercontrol = L.control.layers(basemaps, overlays).addTo(map);
@@ -2333,9 +2336,38 @@ function setMarker(data) {
if (p === true) { marker.openPopup(); }
}
+var custIco = function() {
+ var col = cmd.map.iconColor ?? "#910000";
+ var myMarker = L.VectorMarkers.icon({
+ icon: "circle",
+ markerColor: col,
+ prefix: 'fa',
+ iconColor: 'white'
+ });
+ if (cmd.map.hasOwnProperty("icon")) {
+ myMarker = L.divIcon({
+ className:"faicon",
+ html: '',
+ iconSize: [16, 16],
+ });
+ }
+ var customLayer = L.geoJson(null, {
+ pointToLayer: function(geoJsonPoint, latlng) {
+ //console.log("KML/GPX point",geoJsonPoint)
+ var d = (geoJsonPoint.properties.description || "").trim();
+ var mypop = ''+geoJsonPoint.properties.name + '
'+d+'
lat,lon : ' + geoJsonPoint.geometry.coordinates[1] + ', ' + geoJsonPoint.geometry.coordinates[0];
+ if (geoJsonPoint.geometry.coordinates[2]) {
+ mypop = ''+geoJsonPoint.properties.name + '
'+d+'
lat,lon.alt : ' + geoJsonPoint.geometry.coordinates[1] + ', ' + geoJsonPoint.geometry.coordinates[0] + ', ' + geoJsonPoint.geometry.coordinates[2];
+ }
+ return L.marker(latlng, {icon:myMarker, title:geoJsonPoint.properties.name}).bindPopup(mypop);
+ }
+ });
+ return customLayer;
+}
+
// handle any incoming COMMANDS to control the map remotely
function doCommand(cmd) {
- //console.log("COMMAND",cmd);
+ // console.log("COMMAND",cmd);
if (cmd.init && cmd.hasOwnProperty("maplist")) {
//basemaps = {};
addBaseMaps(cmd.maplist,cmd.layer);
@@ -2535,6 +2567,31 @@ function doCommand(cmd) {
basemaps[baselayername].addTo(map);
}
}
+ // Add a new PMtiles/PBF feature layer
+ if (cmd.map && cmd.map.hasOwnProperty("name") && cmd.map.hasOwnProperty("pmtiles") ) {
+ try {
+ if (basemaps.hasOwnProperty(cmd.map.name)) {
+ basemaps[cmd.map.name].removeFrom(map);
+ existsalready = true;
+ }
+ var opt = {};
+ if (cmd.map.hasOwnProperty("opt")) { opt = cmd.map.opt; }
+ opt.url = cmd.map.pmtiles;
+ opt.attribution = opt.attribution || '© Protomaps';
+ opt.maxDataZoom = opt.maxDataZoom || 15;
+ opt.maxZoom = opt.maxZoom || 20;
+ console.log("New PMtiles:",cmd.map.name,opt);
+ basemaps[cmd.map.name] = protomapsL.leafletLayer(opt);
+ if (!existsalready) {
+ layercontrol.addBaseLayer(basemaps[cmd.map.name],cmd.map.name);
+ }
+ if (Object.keys(basemaps).length === 1) {
+ baselayername = cmd.map.name;
+ basemaps[baselayername].addTo(map);
+ }
+ if (pmtloaded === "") { pmtloaded = cmd.map.name; }
+ } catch(e) { console.log(e); }
+ }
// Add or swap new minimap layer
if (cmd.map && cmd.map.hasOwnProperty("minimap")) {
if (minimap) { map.removeControl(minimap); }
@@ -2696,36 +2753,6 @@ function doCommand(cmd) {
if (cmd.map.hasOwnProperty("fly") && cmd.map.fly === true) { map.flyToBounds(overlays[cmd.map.overlay].getBounds()); }
else if (cmd.map.hasOwnProperty("fit") && cmd.map.fit === true) { map.fitBounds(overlays[cmd.map.overlay].getBounds()); }
}
-
- var custIco = function() {
- var col = cmd.map.iconColor ?? "#910000";
- var myMarker = L.VectorMarkers.icon({
- icon: "circle",
- markerColor: col,
- prefix: 'fa',
- iconColor: 'white'
- });
- if (cmd.map.hasOwnProperty("icon")) {
- myMarker = L.divIcon({
- className:"faicon",
- html: '',
- iconSize: [16, 16],
- });
- }
- var customLayer = L.geoJson(null, {
- pointToLayer: function(geoJsonPoint, latlng) {
- //console.log("KML/GPX point",geoJsonPoint)
- var d = (geoJsonPoint.properties.description || "").trim();
- var mypop = ''+geoJsonPoint.properties.name + '
'+d+'
lat,lon : ' + geoJsonPoint.geometry.coordinates[1] + ', ' + geoJsonPoint.geometry.coordinates[0];
- if (geoJsonPoint.geometry.coordinates[2]) {
- mypop = ''+geoJsonPoint.properties.name + '
'+d+'
lat,lon.alt : ' + geoJsonPoint.geometry.coordinates[1] + ', ' + geoJsonPoint.geometry.coordinates[0] + ', ' + geoJsonPoint.geometry.coordinates[2];
- }
- return L.marker(latlng, {icon:myMarker, title:geoJsonPoint.properties.name}).bindPopup(mypop);
- }
- });
- return customLayer;
- }
-
// Add a new KMZ overlay layer (or KML)
//if (cmd.map && cmd.map.hasOwnProperty("overlay") && cmd.map.hasOwnProperty("kmz")) {
if (cmd.map && cmd.map.hasOwnProperty("overlay") && ( cmd.map.hasOwnProperty("kmz") || cmd.map.hasOwnProperty("kml")) ) {
@@ -2813,7 +2840,7 @@ function doCommand(cmd) {
// var gp = new DOMParser().parseFromString(cmd.map.gpx, "text/xml");
// var json = window.toGeoJSON.gpx(gp);
// console.log("j",json)
- // doGeojson(json.features[0].properties.name,json,json.features[0].properties.type) // DCJ name,geojson,layer,options
+ // doGeojson(json.features[0].properties.name,json,json.features[0].properties.type) // name,geojson,layer,options
overlays[cmd.map.overlay] = omnivore.gpx.parse(cmd.map.gpx, null, custIco());
if (!existsalready) {
layercontrol.addOverlay(overlays[cmd.map.overlay],cmd.map.overlay);
@@ -2939,6 +2966,7 @@ function doCommand(cmd) {
else { lockit = false; doLock(false); }
document.getElementById("lockit").checked = lockit;
}
+ // if (cmd.hasOwnProperty("panlock") && lockit === true) { doLock(true); }
// Move to a new position
var clat = map.getCenter().lat;
var clon = map.getCenter().lng;
@@ -2962,6 +2990,7 @@ function doCommand(cmd) {
document.getElementById("setclus").value = cmd.cluster;
setCluster(clusterAt);
}
+ // Set max age of markers
if (cmd.hasOwnProperty("maxage")) {
document.getElementById("maxage").value = cmd.maxage;
setMaxAge();
@@ -2974,7 +3003,7 @@ function doCommand(cmd) {
// document.getElementById("heatall").checked = !!cmd.heatmap;
// heat.redraw();
}
- if (cmd.hasOwnProperty("panlock") && lockit === true) { doLock(true); }
+ // Lock zoom controls
if (cmd.hasOwnProperty("zoomlock")) {
if (cmd.zoomlock == "true" || cmd.zoomlock == true) {
if (map.doubleClickZoom.enabled()) { map.removeControl(map.zoomControl); }
@@ -2989,7 +3018,8 @@ function doCommand(cmd) {
map.touchZoom.enable();
}
}
- if (cmd.hasOwnProperty("bounds")) { // Move/Zoom map to new bounds
+ // Move/Zoom map to new bounds
+ if (cmd.hasOwnProperty("bounds")) {
if (cmd.bounds.length === 2 && cmd.bounds[0].length === 2 && cmd.bounds[1].length === 2) {
if (cmd.hasOwnProperty("fly") && cmd.fly === true) {
map.flyToBounds(cmd.bounds);