Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'feedback' missing several fields #293

Closed
phreed opened this issue Oct 15, 2024 · 2 comments
Closed

'feedback' missing several fields #293

phreed opened this issue Oct 15, 2024 · 2 comments

Comments

@phreed
Copy link

phreed commented Oct 15, 2024

In v5.0.3
When using 'feedback' as described in
https://flows.nodered.org/node/node-red-contrib-web-worldmap "Events From the Map".

The documentation states that I should expect to get something like:

{"payload": {
   "action": "feedback",
   "name": "some name",
   "value": "some value",
    "lat":51, "lon":0,
     "layer":"unknown" 
     } 
}

The value I am returning is a json object.

{"payload": {
     "name":"my_spot_report",
     "action":"feedback",
     "value":{
       "attitude":"friend",
       "geoObject":"Gnd Equip Vehicle",
       "timeout":"600",
       "name":"jan",
       "bearing":0,
       "distance":1,
       "how":"nonCoT"}
     },
   },
  "topic":"tak-map",
  "_sessionid":"4d8ff0dd-c1d7-41f2-8c13-c70c07f63017",
  "_sessionip":"10.2.118.201",
  "_msgid":"2155e06325ebcb78"
}

The 'lat', 'lon', and 'layer' are all missing.

Is this is the same problem reported in #278 creeping back in?

RedMap/worldmap/worldmap.js

Lines 924 to 941 in 7d1782c

var feedback = function(n = "map",v,a = "feedback",c) {
if (v === "_form") { v = form; }
// undefined is handled directly in the function declaration, but null/"" also requires explicit handling within the function.
n = (n === null || n === "") ? "map" : n;
var dataToSend = { "name": n, "action": a, "value": v };
//Kept only for backward compatibility, as the context menu should handle the click position values internally.
if (n == "map") {
dataToSend.lat = rclk.lat;
dataToSend.lon = rclk.lng;
}
ws.send(JSON.stringify(dataToSend));
if (c === true) { map.closePopup(); }
}
// map.on('click', function(e) {
// ws.send(JSON.stringify({action:"click", lat:e.latlng.lat.toFixed(5), lon:e.latlng.lng.toFixed(5)}));
// });

@phreed
Copy link
Author

phreed commented Oct 15, 2024

It appears that in order to get the lat,lon the 'name' (the first argument of the 'feedback' function) must be 'map'.

If this is not a bug it should be explained in the documentation for the 'feedback' function.

{ "action": "feedback", "name": "some name", "value": "some value", "lat":51, "lon":0, "layer":"unknown" } // when a user calls the feedback function - see below

- **feedback()** : it takes 2, 3, or 4 parameters, name, value, and optionally an action name (defaults to "feedback"), and optional boolean to close the popup on calling this function, and can be used inside something like an input tag - `onchange='feedback(this.name,this.value,null,true)'`. Value can be a more complex object if required as long as it is serialisable. If used with a marker the name should be that of the marker - you can use `${name}` to let it be substituted automatically.

@zafrirron
Copy link
Contributor

zafrirron commented Oct 22, 2024

Feedback Options and Documentation Clarification

The feedback mechanism offers multiple options. The documentation states (under the "Event from the Map" section):

json
Copy code
{ 
  "action": "feedback", 
  "name": "some name", 
  "value": "some value", 
  "lat": 51, 
  "lon": 0, 
  "layer": "unknown" 
} 
// when a user calls the feedback function - see below

This is the default behavior (feedback()), kept only for backward compatibility.

If you are using the feedback as a utility function and wish to report the right mouse click latitude and longitude position, you can use the rclk.lat and rclk.lng variables from your custom feedback code. This allows you to create your own custom feedback content. You could also send other positional data or any other data in the utility use case.

The payload in your issue suggests that you are not using the simple "event from map" option, but rather using feedback as a utility function. In this case, you could build your payload like this:

json
Copy code
{
  "payload": {
    "name": "my_spot_report",
    "action": "feedback",
    "value": {
      "attitude": "friend",
      "geoObject": "Gnd Equip Vehicle",
      "timeout": "600",
      "name": "jan",
      "lat": yourSpotLat,
      "lon": yourSpotLon,
      "bearing": 0,
      "distance": 1,
      "how": "nonCoT"
    }
  },
  "topic": "tak-map",
  "_sessionid": "4d8ff0dd-c1d7-41f2-8c13-c70c07f63017",
  "_sessionip": "10.2.118.201",
  "_msgid": "2155e06325ebcb78"
}

You could inject the spot device reported position the same way you inject the bearing and distance into the utility function.

Refer to the "Moving Icon Demo & Builder" example, where I've added a map context menu using the mouse right-click latitude and longitude to create a new object. The object context menu uses object's position data as default, double-clicking to pull mouse position, but you could also input other position data manually.

@dceejay dceejay closed this as completed Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants