multimap tweaks (#52)
* Multimaps tweaks * fix leading / in worldmap path
This commit is contained in:
parent
428d0aca55
commit
4aaae6358b
@ -76,12 +76,15 @@
|
||||
<label for="node-input-name"><i class="fa fa-file"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="name">
|
||||
</div>
|
||||
<!-- <div class="form-tips">Tip: By default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the map in a new tab.</div>-->
|
||||
<div class="form-tips">Tip: If <i>Path</i> is left empty,
|
||||
then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the map in a new tab.</div>
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="worldmap">
|
||||
<p>Plots "things" on a web map. Needs an internet connection.</p>
|
||||
<!-- <p>Shortcut - <code>⌘⇧m</code> - ctrl-shift-m to jump to Map.</p> -->
|
||||
<p>It is possible to instantiate multiple worldmap nodes but each one must be given a unique
|
||||
path. Worldmap-in nodes are matched to worldmap nodes by having exactly the same path.
|
||||
<p>Shortcut - <code>⌘⇧m</code> - ctrl-shift-m to jump to the default Map (<tt>/worldmap</tt>).</p>
|
||||
<p>The minimum <code>msg.payload</code> must contain <code>name</code>, <code>lat</code> and <code>lon</code> properties, e.g.</p>
|
||||
<pre>{name:"Joe", lat:51, lon:-1.05}</pre>
|
||||
<p><code>name</code> must be a unique identifier.</p>
|
||||
|
@ -35,14 +35,16 @@ module.exports = function(RED) {
|
||||
this.panit = n.panit || "false";
|
||||
this.layers = n.layers || "show";
|
||||
this.path = n.path || "/worldmap";
|
||||
if (this.path.charAt(0) != "/") this.path = "/" + this.path;
|
||||
if (!sockets[this.path]) {
|
||||
var fullPath = path.posix.join(RED.settings.httpNodeRoot, this.path, 'leaflet', 'sockjs.min.js');
|
||||
sockets[this.path] = sockjs.createServer({sockjs_url:fullPath, log:function() {}, transports:"xhr-polling"});
|
||||
sockets[this.path].installHandlers(RED.server, {prefix:path.posix.join(RED.settings.httpNodeRoot,this.path,'socket')});
|
||||
var sockPath = path.posix.join(RED.settings.httpNodeRoot,this.path,'socket');
|
||||
this.log("Serving map "+this.path+" from "+__dirname+" as "+fullPath+" and socket "+sockPath);
|
||||
sockets[this.path].installHandlers(RED.server, {prefix:sockPath});
|
||||
}
|
||||
var node = this;
|
||||
var clients = {};
|
||||
//node.log("Serving map from "+__dirname+" as "+RED.settings.httpNodeRoot.slice(0,-1)+node;path);
|
||||
RED.httpNode.use(node.path, express.static(__dirname + '/worldmap'));
|
||||
|
||||
|
||||
@ -108,6 +110,7 @@ module.exports = function(RED) {
|
||||
var WorldMapIn = function(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
this.path = n.path || "/worldmap";
|
||||
if (this.path.charAt(0) != "/") this.path = "/" + this.path;
|
||||
if (!sockets[this.path]) {
|
||||
var fullPath = path.posix.join(RED.settings.httpNodeRoot, this.path, 'leaflet', 'sockjs.min.js');
|
||||
sockets[this.path] = sockjs.createServer({sockjs_url:fullPath, prefix:path.posix.join(RED.settings.httpNodeRoot,this.path,'socket')});
|
||||
|
Loading…
Reference in New Issue
Block a user