Worldmap Dashboard Map -- Is there a Zoom Extents or Similar?

I am using Worldmap Dashboard node and plotting my wife's and my location pulled from Owntracks onto a Worldmap Dashboard. The map currently centers on the last data point input. Is there a setting that I am missing that will zoom extents of the 2 data points or do I have to do some math?

I can calculate the average of our two latitude and longitude values. I thought I could then send that average as a command to the Worldmap but I got error messages of "Cannot set property of non-object type: payload.command.lat" and same for longitude.

The better but more complicated method would to set the bounds of the map based on our coordinates. It just adds the complication of determining the max & min values for latitude & longitude each to enter in the bounds array.

Is anyone else doing similar that can suggestions?

You should be able to set the centre of the map (and zoom) by a command as you suggest. Can you share an example of what you have tried ?
You can also set a bounds command to an array of two corner coordinates. IE an array with two arrays inside.

I am sure I am missing something simple. I am using 2 nodes to calculate the command values that are then sent to the Worldmap Dashboard Node:

where the function node is:
image

and the Change Node is:
image

I know I should be able to do everything in the Change Node within the Function Node but when I couldn't get it to work, I pullled that out and tried doing the final part in the Change Node. The Function Node is sending the values that I want. I try to avoid Function Nodes like the plague so that's probably not the best way to do it.

I think I figured it out. If I understand correctly, msg.payload is a string coming out of function node. In order to assign values to it, it has to be an object so I first must declare that in the Change Node using "{}" I added that to first item like this and it seemed to solve the problem. Is there a way to do this inside the Function Node instead to save me a node?

image

We are both home so I can't do full test until we are both somewhere else. Once I confirm this is working, I will move to defining the bounds instead.

To be sure I would set msg.payload to {command:{}} so that the command property is created blank as well first - but then yes looks good.

msg.payload = {command: {lon: lonAve, lat: atAve}}

If you don't need msg.latAve and msg.lonAve for other reasons then you can remove those lines.

I originally got it working with additional lines of setting msg.payload.lon and msg.payload.lat to {}. Then, I deleted to see if it would still work and it seems to. Thanks for help. This map is much more user-friendly than relying on the Owntracks Map.

EDIT:

SUCCESS!!! This worked and without the need for the Change Node!
image

@dceejay and @Colin Thank you for your assistance. I know it's not a complicated Function Node/Flow but it's a big win for a Function Node newbie like me. :grinning:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.