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
|
else if (value.match(w3)) { // see if it's 3 dot separated words
|
||||||
node.w3w.wordsToPosition({ words:value })
|
node.w3w.wordsToPosition({ words:value })
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
value.lat = Number(response.split(",")[0]);
|
var loc = {};
|
||||||
value.lon = Number(response.split(",")[1]);
|
loc.lat = Number(response.split(",")[0]);
|
||||||
RED.util.setMessageProperty(msg,node.property,value);
|
loc.lon = Number(response.split(",")[1]);
|
||||||
|
RED.util.setMessageProperty(msg,"location",loc);
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
@ -56,10 +57,10 @@ module.exports = function(RED) {
|
|||||||
else if (value.match(w1)) { // see if it's a *Oneword
|
else if (value.match(w1)) { // see if it's a *Oneword
|
||||||
node.w3w.wordsToPosition({ words:value })
|
node.w3w.wordsToPosition({ words:value })
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
if (!msg.hasOwnProperty("location")) { value = {}; }
|
var loc = {};
|
||||||
value.lat = Number(response.split(",")[0]);
|
loc.lat = Number(response.split(",")[0]);
|
||||||
value.lon = Number(response.split(",")[1]);
|
loc.lon = Number(response.split(",")[1]);
|
||||||
value = response;
|
RED.util.setMessageProperty(msg,"location",loc);
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user