geolocation - Geocoding node-red-node-google. Error "Invalid request. Invalid 'latlng' parameter" -


i´m not expert in node-red , appreciate on using node-red-node-google geocoding node. link google geolocation node-red node

i'm trying obtain location address via google geolocation api obtained coordinates using node mentioned above (geocode coordinates option). take latitude , length via post external application.

how should latitude , longitude data fed geocode node correct address data? after tens of tests, obtain same error: "invalid request. invalid 'latlng' parameter". i'm doing is:

  1. take data generated via post http://my_public_ip:1880/geo?id={device}&time={time}&lat={lat}&lng={lng}&radius={radius} first node of flow node-red http in node, implements htp end-point, gets info callback. te info retrieved correctly (see debug output) : {"id":"18a834","time":"1503231980","lat":"40.xxxxxxxxxxxxxx","lng":"-3.xxxxxxxxxxxxxx","radius":"1651"} note: coordinates shadowed privacy reasons.
  2. if lng , lat values http in node fed google geocoding node, message error "invalid request. invalid 'latlng' parameter" received.

i fill dialog box way:

latitude text box: msg.payload.lat

longitude text box:msg.payload.lng

  1. i have tried several options inserting coords function node: convert latitude , longitude values float, keep first 7 decimals, convert again strings ..., , same error received: "invalid request. invalid 'latlng' parameter"

the coords function node configuration:

var coords ={}; latitude= parsefloat(msg.payload.lat).tofixed(7); latitude1 = parsefloat(latitude); var length = parsefloat(msg.payload.lng).tofixed(7); var length1= parsefloat(length); coords.payload = {lat:latitude1, lng:length1}; return coords; 

the function output seems correct: {"lat":40.xxxxxxx,"lng":-3.xxxxxxx}

so expected fill text boxes msg.payload.lat , msg.payload.lng should ok. wrong ...

does know correct way feed longitude , latitude values node-red-node-google google-geocoding no errors? find below node-red used code (remember, tested different types of variable , tested no function @ all):

[{"id":"4dadb4d9.246a1c","type":"http in","z":"76138ea1.88752","name":"get_coords_from_post","url":"/geo","method":"get","upload":false,"swaggerdoc":"","x":300,"y":200,"wires":[["4a0b74fb.d10fcc","fb89b080.ef1cf","dac1b7ce.4cc2c8"]]},{"id":"fb89b080.ef1cf","type":"function","z":"76138ea1.88752","name":"coords","func":"var coords ={};\nlatitude= parsefloat(msg.payload.lat).tofixed(7);\nlatitude1 = parsefloat(latitude);\nvar length = parsefloat(msg.payload.lng).tofixed(7);\nvar length1= parsefloat(length);\ncoords.payload = {lat:latitude1, lng:length1};\nreturn coords; \n","outputs":1,"noerr":0,"x":510,"y":200,"wires":[["a24b08cf.22ebf8","dac1b7ce.4cc2c8"]]},{"id":"4a0b74fb.d10fcc","type":"http response","z":"76138ea1.88752","name":"","statuscode":"","headers":{},"x":484,"y":131,"wires":[]},{"id":"dac1b7ce.4cc2c8","type":"debug","z":"76138ea1.88752","name":"","active":true,"console":"false","complete":"false","x":990,"y":480,"wires":[]},{"id":"a24b08cf.22ebf8","type":"google geocoding","z":"76138ea1.88752","name":"find_address_from_coords","geocodeby":"coordinates","address":"","lat":"msg.payload.lat","lon":"msg.payload.lng","googleapi":"","bounds":"","language":"es","region":"","components":"","x":740,"y":200,"wires":[["dac1b7ce.4cc2c8"]]}] 

you shouldn't putting msg.payload.lat or msg.payload.lon in config dialog. if passing values in via message object need leave them blank in config dialog.

next, mentioned in readme.md , info bar in node-red, need set msg.location.lat , msg.location.lon on incoming message pass value node.

so function node should little bit more this:

var coords ={}; latitude= parsefloat(msg.payload.lat).tofixed(7); latitude1 = parsefloat(latitude); var length = parsefloat(msg.payload.lng).tofixed(7); var length1= parsefloat(length); coords.location = {lat:latitude1, lon:length1}; return coords; 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -