node-red-node-google

355 views
Skip to first unread message

Dallas Toth

unread,
Jun 23, 2015, 4:47:47 PM6/23/15
to node...@googlegroups.com
I have things pretty much working but one thing. The Address field in the Google Geocoding if I fill it in with an address it gets the lat lon no problem. 
But I am wanting to pass in the address via a (msg.payload/msg.location)  and no mater what I try to pass in as strings or arrays I can not get it to take the payloads I have sending to the node.
So if you could give me a hand or point me in the right direction. Do I leave the Address Blank in the node or fill it in with msg.payload/msg.location? 
There is a mention of  "All of the following parameters can be supplied as part of the top level 
msg object" I am not sure where that is and what I need to change to get my msg passed into the Google Geocode node. Is that what I am missing?

The flow I am working on involves passing in address's from a MSSQL db thru to the Google Geocode to map out points and location of clients on the map. At least it's a start to what I am looking to do with the Node package.

Thanks for any help you can provide.

Mark Setrem

unread,
Jun 24, 2015, 5:38:36 AM6/24/15
to node...@googlegroups.com

As is described in the info panel for the node.  You need to put the address in:


msg.location.address - Address to be sent to Google in order to be converted to a set of coordinates. (Required if using Geocode by Address)

The address panel in the edit dialogue box needs to be blank.

This flow works for me...
[{"id":"29abc4b9.d6543c","type":"google geocoding","name":"","geocodeBy":"address","address":"","lat":"","lon":"","googleAPI":"","bounds":"","language":"","region":"","components":"","x":424,"y":202,"z":"5bdb1411.a424ec","wires":[["289cbf76.d7634"]]},{"id":"6c40ea27.93bf14","type":"inject","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":140,"y":201,"z":"5bdb1411.a424ec","wires":[["f9cba998.063458"]]},{"id":"289cbf76.d7634","type":"debug","name":"","active":true,"console":"false","complete":"true","x":584,"y":202,"z":"5bdb1411.a424ec","wires":[]},{"id":"f9cba998.063458","type":"function","name":"","func":"msg.location=[];\nmsg.location.address = \"Times Square, Manhattan, NY 10036\";\nreturn msg;","outputs":1,"noerr":0,"x":262,"y":201,"z":"5bdb1411.a424ec","wires":[["29abc4b9.d6543c"]]}]

jo2

unread,
Jun 24, 2015, 5:57:16 AM6/24/15
to node...@googlegroups.com
Hi!

I think this should work as desired. I am using this is some of my nodes - where a UI field value can be overridden by msg value(s) when the nodes "input" event is triggered.

E.g. I have something like this below. The config object contains the UI field values. On "inpu" I check if msg (or msg.payload) contains the same properties...

Maybe not what you are looking for?!

Cheers
-jo

.....
  function LookupPlace(config) {
    RED.nodes.createNode(this, config);

    this.username = config.username;
    this.style = config.style;
    this.latitude = config.latitude;
    this.longitude = config.longitude;
    this.debug = config.debug;

    var node = this;

    this.on('input', function(msg) {
      var username = msg.username || msg.payload.username || node.username;
      var style = msg.style || msg.payload.style || node.style;
      var latitude = msg.latitude || msg.payload.latitude || node.latitude;
      var longitude = msg.longitude || msg.payload.longitude || node.longitude;

      debugLog(msg.latitude, msg.payload.latitude, node.latitude);
      debugLog(username, style, latitude, longitude);

.....

 

Dallas Toth

unread,
Jun 24, 2015, 10:17:29 AM6/24/15
to node...@googlegroups.com
msg.location=[];
msg.location.address = msg.payload;
return msg;

Worked, Thank you so much. Now onto the multiple address pins.

--
http://nodered.org
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/XooJ1BbK57s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave C-J

unread,
Jun 24, 2015, 1:53:54 PM6/24/15
to node...@googlegroups.com
Jo

we deliberately chose the opposite course of action...   If someone specifies something in the edit box then we assume they did so for a reason...  allowing the msg to override it will provide unexpected behaviour... as the user will say "I said to do this and it did something else"...   if left blank then the msg properties can set it.  This is the way round we have it for all the core nodes.

Dallas Toth

unread,
Jun 24, 2015, 4:31:14 PM6/24/15
to node...@googlegroups.com
So by the look of things Google Geocode only works with a single address in the msg.location.address at a time. Anyone have success with passing in multiple. I tried this in the function.
msg.location=[];
msg.location.address = [{"":"Times Square, Manhattan, NY 10036"},{"":"Yankee Stadium 1 E 161st St Bronx, NY 10451"}];
return msg;


I know the LiveMap supports passing in multiple pins and that is what I am looking to do. Pass in multiple Address's and have them Geocode to the lat/lng for the Livemap.


On Wed, Jun 24, 2015 at 11:53 AM, Dave C-J <dce...@gmail.com> wrote:
Jo

we deliberately chose the opposite course of action...   If someone specifies something in the edit box then we assume they did so for a reason...  allowing the msg to override it will provide unexpected behaviour... as the user will say "I said to do this and it did something else"...   if left blank then the msg properties can set it.  This is the way round we have it for all the core nodes.

--

jo2

unread,
Jun 30, 2015, 7:09:39 PM6/30/15
to node...@googlegroups.com
Hi Dave!
Yes i have seen discussions on this, and think it is the most intuitive way.
So the assignment should be changed to something like this I guess:
node.style = node.style ? node.style : msg.payload.style;

I tend to use the UI values for initial testing, and then go on using msg
runtime values. And often forget to empty UI fields. And sometimes
i use them for default values. Find it handy, but realize it can be harder
to go back later and understand the flow details. Have some tidying up to do :-)

-jo

jo2

unread,
Jun 30, 2015, 7:13:07 PM6/30/15
to node...@googlegroups.com
Like this it should be...
Reply all
Reply to author
Forward
0 new messages