Skip to content

Commit c23d7a2

Browse files
committed
add countries overlay if absolutely no baselayers
1 parent 6eac842 commit c23d7a2

File tree

4 files changed

+17
-23
lines changed

4 files changed

+17
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### Change Log for Node-RED Worldmap
22

3+
- v5.5.2 - Slight improvement for on/offline choice of map
34
- v5.5.1 - Fix maxNativeZoom for pmtiles to pull from tiles files. Issue #312
45
- v5.5.0 - Add ability to load raster pmtiles files. Issue #312
56
- v5.4.0 - Let msg.payload.command.zoomLevels set an array of acceptable zoom levels. Issue #312

README.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
# node-red-contrib-web-worldmap
22

3+
A <a href="https://nodered.org" target="mapinfo">Node-RED</a> node to provide a world map web page for plotting "things" on. Please feel free to [![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/dceejay) this project.
4+
35
[![platform](https://img.shields.io/badge/platform-Node--RED-red)](https://nodered.org)
46
![NPM version](https://badge.fury.io/js/node-red-contrib-web-worldmap.svg)
57
[![GitHub license](https://img.shields.io/github/license/dceejay/redmap.svg)](https://github.com/dceejay/redmap/blob/master/LICENSE)
68

7-
A <a href="https://nodered.org" target="mapinfo">Node-RED</a> node to provide a world
8-
map web page for plotting "things" on.
9-
10-
Feel free to [![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/dceejay) this project.
11-
129
![Map Image](https://dceejay.github.io/pages/images/redmap.png)
1310

1411
### Updates
1512

13+
- v5.5.2 - Slight improvement for on/offline choice of map
1614
- v5.5.1 - Fix maxNativeZoom for pmtiles to pull from tiles files. Issue #312
1715
- v5.5.0 - Add ability to load raster pmtiles files. Issue #312
1816
- v5.4.0 - Let msg.payload.command.zoomLevels set an array of acceptable zoom levels. Issue #312
@@ -24,15 +22,6 @@ Feel free to [![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%
2422
- v5.1.2 - Fix for longer line msg properties.
2523
- v5.1.1 - Fix CoT inline image.
2624
- v5.1.0 - Let special icons be sizeable using iconSize property.
27-
- v5.0.9 - Slight tidy on flags, bump turf dep.
28-
- v5.0.8 - Fix flag handling for SIDC 2525D, add example.
29-
- v5.0.7 - Allow Tooltip options (see new example). PR #295.
30-
- v5.0.6 - Tweak SIDC flag handling slightly to show direction if available and moving.
31-
- v5.0.4 - Tweak CoT handling slightly.
32-
- v5.0.3 - Add great context menu example flow. PR #290. Bump express lib. PR #291.
33-
- v5.0.2 - Fix sidcEdgeIcon docs PR #289.
34-
- v5.0.1 - Fix isArray error PR #288.
35-
- v5.0.0 - Feedback cleanup PR #281, edgeicons option PR #287, bump libs for vuln fixes.
3625

3726
- see [CHANGELOG](https://github.com/dceejay/RedMap/blob/master/CHANGELOG.md) for full list of changes.
3827

@@ -97,6 +86,8 @@ If you use the name without the fa- prefix (eg `male`) you will get the icon ins
9786

9887
You can also specify an emoji as the icon by using the :emoji name: syntax - for example `:smile:`. Here is a **[list of emojis](https://github.com/dceejay/RedMap/blob/master/emojilist.md)**.
9988

89+
Note: Not all browsers/OS support unicode emoji - if you can see the Swiss flag here (🇨🇭) then you may be OK.
90+
10091
Or you can specify an image to load as an icon by setting the icon to `http(s)://...` By default it will be scaled to 32x32 pixels. You can change the size by setting **iconSize** to a number of pixels - eg 64. Example icon - `"https://img.icons8.com/windows/32/000000/bird.png"` or you can use an inline image of the form `data:image/...` which uses a base64 encoded image.
10192

10293
There are also several special icons...
@@ -143,8 +134,6 @@ There are lots of extra options you can specify as `msg.payload.options` - see t
143134

144135
Note: If the SIDC code is a 2525C 15 characters long, where chars 13 and 14 are a country code - then the country flag emoji is added to the staffComments field of the icon. If it's a 20 char 2525D code then the options:country property will be used to create the flag.
145136

146-
Note: Not all browsers/OS support unicode emoji - if you can see the Swiss flag here (🇨🇭) then you may be OK.
147-
148137
#### TAK Visualisation
149138

150139
Users of [TAK](https://tak.gov) can use the [TAK ingest node](https://flows.nodered.org/node/node-red-contrib-tak-registration) to create a JSON formatted TAK event object, received from a TAK server. This can be fed directly into the worldmap node.

worldmap.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ module.exports = function(RED) {
131131
client.write(JSON.stringify({command:c}));
132132
for (var p=0; p < pmtiles.length; p++) {
133133
fs.symlink(RED.settings.userDir+'/'+pmtiles[p], __dirname+'/worldmap/'+pmtiles[p], 'file', (err) => {
134-
if (err) {
135-
if (err.code !== "EEXIST") { console.log(err); }
136-
}
134+
if (err && err.code !== "EEXIST") { console.log(err); }
137135
})
138136
client.write(JSON.stringify({command: {map: {name:pmtiles[p].split('.')[0], pmtiles:pmtiles[p], opt:pmtilesopts }}}));
139137
node.log("Added pmtiles file: "+pmtiles[p]);

worldmap/worldmap.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,15 @@ var customTopoLayer = L.geoJson(null, {clickable:false, style: {color:"blue", we
181181
layers["_countries"] = omnivore.topojson('images/world-50m-flat.json',null,customTopoLayer);
182182
overlays["countries"] = layers["_countries"];
183183

184-
var onoffline = function() { if (!navigator.onLine) {
185-
if (pmtloaded !== "") { basemaps[pmtloaded].addTo(map); layercontrol._update(); }
186-
else { map.addLayer(overlays["countries"]); }
187-
} }
184+
var onoffline = function() {
185+
if (!navigator.onLine) {
186+
if (pmtloaded !== "") { basemaps[pmtloaded].addTo(map); layercontrol._update(); }
187+
else { map.addLayer(overlays["countries"]); }
188+
}
189+
else if (Object.keys(basemaps).length === 0 ) {
190+
map.addLayer(overlays["countries"]);
191+
}
192+
}
188193

189194
document.addEventListener ("keydown", function (ev) {
190195
// Set Ctl-Alt-3 to switch to 3d view
@@ -2739,6 +2744,7 @@ function doCommand(cmd) {
27392744
}
27402745
if (h.tileType === 1) {
27412746
opt.url = cmd.map.pmtiles;
2747+
if (!opt.maxDataZoom) { opt.maxDataZoom = h.maxZoom || 15; }
27422748
basemaps[cmd.map.name] = protomapsL.leafletLayer(opt);
27432749
}
27442750
else {

0 commit comments

Comments
 (0)