node-red-contrib-web-worldmap 2.24.1 → 2.26.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.
@@ -565,8 +565,8 @@ map.on('overlayadd', function(e) {
565
565
  }
566
566
  if (e.name == "drawing") {
567
567
  overlays["drawing"].bringToFront();
568
- map.addControl(drawControl);
569
568
  map.addControl(colorControl);
569
+ map.addControl(drawControl);
570
570
  }
571
571
  ws.send(JSON.stringify({action:"addlayer", name:e.name}));
572
572
  });
@@ -579,8 +579,8 @@ map.on('overlayremove', function(e) {
579
579
  layers["_daynight"].clearLayers();
580
580
  }
581
581
  if (e.name == "drawing") {
582
- map.removeControl(colorControl);
583
582
  map.removeControl(drawControl);
583
+ map.removeControl(colorControl);
584
584
  }
585
585
  ws.send(JSON.stringify({action:"dellayer", name:e.name}));
586
586
  });
@@ -922,13 +922,15 @@ var addOverlays = function(overlist) {
922
922
  // Add the drawing layer...
923
923
  if (overlist.indexOf("DR")!==-1) {
924
924
  //var colorPickButton = L.easyButton({states:[{icon:'fa-tint fa-lg', onClick:function() { console.log("PICK"); }, title:'Pick Colour'}]});
925
- var redButton = L.easyButton('fa-square wm-red', function(btn) { changeDrawColour("#E7827F"); })
926
- var blueButton = L.easyButton('fa-square wm-blue', function(btn) { changeDrawColour("#94CCE2"); })
927
- var greenButton = L.easyButton('fa-square wm-green', function(btn) { changeDrawColour("#ACD6A4"); })
928
- var yellowButton = L.easyButton('fa-square wm-yellow', function(btn) { changeDrawColour("#F5F08B"); })
929
- var blackButton = L.easyButton('fa-square wm-black', function(btn) { changeDrawColour("#444444"); })
925
+ var redButton = L.easyButton('fa-square wm-red', function(btn) { changeDrawColour("#FF4040"); })
926
+ var blueButton = L.easyButton('fa-square wm-blue', function(btn) { changeDrawColour("#4040F0"); })
927
+ var greenButton = L.easyButton('fa-square wm-green', function(btn) { changeDrawColour("#40D040"); })
928
+ var yellowButton = L.easyButton('fa-square wm-yellow', function(btn) { changeDrawColour("#FFFF40"); })
929
+ var cyanButton = L.easyButton('fa-square wm-cyan', function(btn) { changeDrawColour("#40F0F0"); })
930
+ var magentaButton = L.easyButton('fa-square wm-magenta', function(btn) { changeDrawColour("#F040F0"); })
931
+ var blackButton = L.easyButton('fa-square wm-black', function(btn) { changeDrawColour("#000000"); })
930
932
  var whiteButton = L.easyButton('fa-square wm-white', function(btn) { changeDrawColour("#EEEEEE"); })
931
- colorControl = L.easyBar([redButton,blueButton,greenButton,yellowButton,blackButton,whiteButton]);
933
+ colorControl = L.easyBar([redButton,blueButton,greenButton,yellowButton,cyanButton,magentaButton,blackButton,whiteButton]);
932
934
 
933
935
  layers["_drawing"] = new L.FeatureGroup();
934
936
  overlays["drawing"] = layers["_drawing"];
@@ -953,7 +955,7 @@ var addOverlays = function(overlist) {
953
955
  });
954
956
  var changeDrawColour = function(col) {
955
957
  drawingColour = col;
956
- console.log("COL",col)
958
+ console.log("COLOR",col)
957
959
  drawControl.setDrawingOptions({
958
960
  polyline: { shapeOptions: { color:drawingColour } },
959
961
  circle: { shapeOptions: { color:drawingColour } },
@@ -1197,16 +1199,7 @@ layercontrol = L.control.layers(basemaps, overlays);
1197
1199
  if (!inIframe) { layercontrol.addTo(map); }
1198
1200
  else { showLayerMenu = false;}
1199
1201
 
1200
- var coords = L.control.coordinates({
1201
- position:"bottomleft", //optional default "bottomright"
1202
- decimals:4, //optional default 4
1203
- decimalSeperator:".", //optional default "."
1204
- labelTemplateLat:" Lat: {y}", //optional default "Lat: {y}"
1205
- labelTemplateLng:" Lon: {x}", //optional default "Lng: {x}"
1206
- enableUserInput:false, //optional default true
1207
- useDMS:true, //optional default false
1208
- useLatLngOrder: true, //ordering of labels, default false-> lng-lat
1209
- });
1202
+ var coords = L.control.mouseCoordinate({position:"bottomleft"});
1210
1203
 
1211
1204
  // Add an optional legend
1212
1205
  var legend = L.control({ position: "bottomleft" });
@@ -2085,7 +2078,7 @@ function setMarker(data) {
2085
2078
  function doCommand(cmd) {
2086
2079
  // console.log("COMMAND",cmd);
2087
2080
  if (cmd.init && cmd.hasOwnProperty("maplist")) {
2088
- basemaps = [];
2081
+ //basemaps = {};
2089
2082
  addBaseMaps(cmd.maplist,cmd.layer);
2090
2083
  }
2091
2084
  if (cmd.init && cmd.hasOwnProperty("overlist")) {
@@ -2191,16 +2184,13 @@ function doCommand(cmd) {
2191
2184
  if (cmd.hasOwnProperty("coords")) {
2192
2185
  try { coords.removeFrom(map); }
2193
2186
  catch(e) {}
2194
- if (cmd.coords == "dms") {
2195
- coords.options.useDMS = true;
2196
- showMouseCoords = "dms";
2197
- coords.addTo(map);
2198
- }
2199
- if (cmd.coords == "deg") {
2200
- coords.options.useDMS = false;
2201
- showMouseCoords = "deg";
2202
- coords.addTo(map);
2203
- }
2187
+ var opts = {gps:false, gpsLong:false, utm:false, utmref:false, position:"bottomleft"}
2188
+ if (cmd.coords == "deg") { opts.gps = true; }
2189
+ if (cmd.coords == "dms") { opts.gpsLong = true; }
2190
+ if (cmd.coords == "utm") { opts.utm = true; }
2191
+ if (cmd.coords == "mgrs") { opts.utmref = true; }
2192
+ coords.options = opts;
2193
+ coords.addTo(map);
2204
2194
  }
2205
2195
  if (cmd.hasOwnProperty("legend")) {
2206
2196
  if (typeof cmd.legend === "string" && cmd.legend.length > 0) {
@@ -2211,7 +2201,7 @@ function doCommand(cmd) {
2211
2201
  return div;
2212
2202
  };
2213
2203
  legend.addTo(map);
2214
- };
2204
+ }
2215
2205
  legend.getContainer().style.visibility = 'visible'; // if already exist use visibility to show/hide
2216
2206
  legend.getContainer().innerHTML = cmd.legend; // set content of legend
2217
2207
  }
@@ -2620,6 +2610,11 @@ function doCommand(cmd) {
2620
2610
  map.touchZoom.enable();
2621
2611
  }
2622
2612
  }
2613
+ if (cmd.hasOwnProperty("bounds")) { // Move/Zoom map to new bounds
2614
+ if (cmd.bounds.length === 2 && cmd.bounds[0].length === 2 && cmd.bounds[1].length === 2) {
2615
+ map.fitBounds(cmd.bounds);
2616
+ }
2617
+ }
2623
2618
  }
2624
2619
 
2625
2620
  // handle any incoming GEOJSON directly - may style badly
@@ -2650,7 +2645,7 @@ function doGeojson(n,g,l,o) {
2650
2645
  st.fillColor = feature.style["fill-color"] || feature.style["fill"] || st.fillColor;
2651
2646
  st.fillOpacity = feature.style["fill-opacity"] || st.fillOpacity;
2652
2647
  }
2653
- if (feature.hasOwnProperty("geometry") && feature.geometry.hasOwnProperty("type") && feature.geometry.type === "LineString") {
2648
+ if (feature.hasOwnProperty("geometry") && feature.geometry.hasOwnProperty("type") && (feature.geometry.type === "LineString" || feature.geometry.type === "MultiLineString") ) {
2654
2649
  st.fill = false;
2655
2650
  }
2656
2651
  return st;
package/worldmap.html CHANGED
@@ -83,6 +83,8 @@
83
83
  <option value="none">Not shown</option>
84
84
  <option value="deg">Degrees</option>
85
85
  <option value="dms">D.M.S</option>
86
+ <option value="utm">UTM</option>
87
+ <option value="mgrs">MGRS</option>
86
88
  </select>
87
89
  <i class="fa fa-th" style="margin-left:22px;"></i> Graticule
88
90
  <select id="node-input-showgrid" style="width:101px;">
@@ -239,6 +241,8 @@ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>c
239
241
  <option value="none">Not shown</option>
240
242
  <option value="deg">Degrees</option>
241
243
  <option value="dms">D.M.S</option>
244
+ <option value="utm">UTM</option>
245
+ <option value="mgrs">MGRS</option>
242
246
  </select>
243
247
  <i class="fa fa-th" style="margin-left:22px;"></i> Graticule
244
248
  <select id="node-input-showgrid" style="width:101px;">
package/worldmap.js CHANGED
@@ -54,6 +54,9 @@ module.exports = function(RED) {
54
54
  //node.log("Serving "+__dirname+" as "+node.path);
55
55
  node.log("started at "+node.path);
56
56
  var clients = {};
57
+ RED.httpNode.get("/-worldmap3d-key", RED.auth.needsPermission('worldmap3d.read'), function(req, res) {
58
+ res.send({key:process.env.MAPBOXGL_TOKEN||""});
59
+ });
57
60
  RED.httpNode.use(compression());
58
61
  RED.httpNode.use(node.path, express.static(__dirname + '/worldmap'));
59
62
  // RED.httpNode.use(node.path, express.static(__dirname + '/worldmap', {maxage:3600000}));