mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Fixed What3Words words>location method (#518)
* Fixed What3Words words>location method * Update what3words.js added fix to Oneword
This commit is contained in:
parent
81781539f7
commit
ac2f9ad8c6
@ -44,9 +44,10 @@ module.exports = function(RED) {
|
||||
else if (value.match(w3)) { // see if it's 3 dot separated words
|
||||
node.w3w.wordsToPosition({ words:value })
|
||||
.then(function(response) {
|
||||
value.lat = Number(response.split(",")[0]);
|
||||
value.lon = Number(response.split(",")[1]);
|
||||
RED.util.setMessageProperty(msg,node.property,value);
|
||||
var loc = {};
|
||||
loc.lat = Number(response.split(",")[0]);
|
||||
loc.lon = Number(response.split(",")[1]);
|
||||
RED.util.setMessageProperty(msg,"location",loc);
|
||||
node.send(msg);
|
||||
})
|
||||
.catch(function(err) {
|
||||
@ -56,10 +57,10 @@ module.exports = function(RED) {
|
||||
else if (value.match(w1)) { // see if it's a *Oneword
|
||||
node.w3w.wordsToPosition({ words:value })
|
||||
.then(function(response) {
|
||||
if (!msg.hasOwnProperty("location")) { value = {}; }
|
||||
value.lat = Number(response.split(",")[0]);
|
||||
value.lon = Number(response.split(",")[1]);
|
||||
value = response;
|
||||
var loc = {};
|
||||
loc.lat = Number(response.split(",")[0]);
|
||||
loc.lon = Number(response.split(",")[1]);
|
||||
RED.util.setMessageProperty(msg,"location",loc);
|
||||
node.send(msg);
|
||||
})
|
||||
.catch(function(err) {
|
||||
|
Loading…
Reference in New Issue
Block a user