node-red-contrib-web-worldmap 4.5.1 → 4.5.2
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 +2 -1
- package/README.md +5 -0
- package/package.json +1 -1
- package/worldmap.js +14 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
### Change Log for Node-RED Worldmap
|
|
2
2
|
|
|
3
|
-
- v4.5.
|
|
3
|
+
- v4.5.2 - Tidy up when pmtiles removed.
|
|
4
|
+
- v4.5.0 - Fix pmtiles to look for maps in userdir rather than modules.
|
|
4
5
|
- v4.4.0 - Add quad(copter) drone icon.
|
|
5
6
|
- v4.3.3 - Fix for objects changing layers.
|
|
6
7
|
- v4.3.2 - Fix geojson popup missing label name.
|
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ Feel free to [ drone icon.
|
|
18
19
|
- v4.3.3 - Fix for objects changing layers.
|
|
@@ -723,6 +724,10 @@ You can use a PMtiles format map archive file from [Protomaps](https://docs.prot
|
|
|
723
724
|
|
|
724
725
|
Copy your .pmtiles file(s) into your `~/.node-red` user directory. On re-starting Node-RED the node will detect the file(s) and add them to the base map layer menu, using the file name as the layer name.
|
|
725
726
|
|
|
727
|
+
You can also load them dynamically with a command like
|
|
728
|
+
|
|
729
|
+
msg.payload = {"command":{"map":{"name":"MyMap","pmtiles":"/path/to/mymap.pmtiles"}}}
|
|
730
|
+
|
|
726
731
|
### Using a Docker Map Server
|
|
727
732
|
|
|
728
733
|
I have found the easiest to use mapserver for decent generic map to be Tileserver-gl. It uses mbtiles format maps - for example from [MapTiler Data](https://data.maptiler.com/downloads/planet/). You can download your mbtiles file into a directory and then from that directory run
|
package/package.json
CHANGED
package/worldmap.js
CHANGED
|
@@ -13,8 +13,9 @@ module.exports = function(RED) {
|
|
|
13
13
|
if (fs.existsSync((__dirname + '/mapserv'))) {
|
|
14
14
|
RED.httpNode.use("/cgi-bin/mapserv", require('cgi')(__dirname + '/mapserv'));
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
var pmtiles = fs.readdirSync(__dirname + '/worldmap').filter(fn => fn.endsWith('.pmtiles'));
|
|
17
|
+
pmtiles.forEach(file => { fs.unlinkSync(__dirname + '/worldmap/'+file); })
|
|
18
|
+
pmtiles = fs.readdirSync(RED.settings.userDir).filter(fn => fn.endsWith('.pmtiles'));
|
|
18
19
|
|
|
19
20
|
function worldMap(node, n) {
|
|
20
21
|
var allPoints = {};
|
|
@@ -163,6 +164,17 @@ module.exports = function(RED) {
|
|
|
163
164
|
|
|
164
165
|
node.on('input', function(msg) {
|
|
165
166
|
if (!msg.hasOwnProperty("payload")) { node.warn("Missing payload"); return; }
|
|
167
|
+
|
|
168
|
+
if (msg.payload.hasOwnProperty("command") && msg.payload.command.hasOwnProperty("map") && msg.payload.command.map.hasOwnProperty("pmtiles")) {
|
|
169
|
+
if (msg.payload.command.map.pmtiles.indexOf("http") !== 0) {
|
|
170
|
+
fs.symlink(msg.payload.command.map.pmtiles, __dirname+'/worldmap/'+msg.payload.command.map.name+'.pmtiles', 'file', (err) => {
|
|
171
|
+
if (err) {
|
|
172
|
+
if (err.code !== "EEXIST") { console.log(err); }
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
msg.payload.command.map.pmtiles = msg.payload.command.map.name+'.pmtiles';
|
|
176
|
+
}
|
|
177
|
+
}
|
|
166
178
|
if (msg.hasOwnProperty("_sessionid")) {
|
|
167
179
|
if (clients.hasOwnProperty(msg._sessionid)) {
|
|
168
180
|
clients[msg._sessionid].write(JSON.stringify(msg.payload));
|