Converting remote asset UDTs into dynamic map markers

I have a project that I am trying to proof of concept for a customer with Ignition. There are a number of large remote assets that run on construction sites, so their location is dynamic. I’d like to model all the assets with UDTs containing the location data and keep them in a single tag folder.

The screen I’d like to make uses the Map component. I’d like to do something akin to a forEach loop, grab each UDT (and their lat/lng), and turn them into markers.

Is there a way to loop through all the UDT’s in a folder and work off of them somehow? Scripting? I suppose I could create some database tables and keep the assets tied to coordinates in there. That seems a little convoluted though - maybe someone a better solution that’s a little more simple. Thanks for any help.

system.tag.browse can be used for the ‘list UDT instances in a folder’ piece of this. There are some performance ramifications to be aware of, but a flat (non-recursive) browse of a single folder should be pretty safe.

1 Like

That’s a great start for it. I’m just getting into the scripting world, so that’s a really good springboard to get moving on. Thanks

So after a fun day, I did get it working. The script browses the UDT folder and concocts markers after grabbing the relevant parts from the UDT.

I feel like I did it a bit hacky by using scripts and expression transforms on the marker tag binding. The issue I had to hack around was how to get the script to trigger and update. My solution was using a dummy query that would poll super lazily and eventually update things. Maybe I’ll find a better way to implement it, but it’s working for the proof of concept!

1 Like

Hey Sam,

Instead of using a dummy query, I would recommend switching to an expression structure binding.

You can have many inputs to the binding and use a single script transform. To make it poll, make one of the inputs a now(x) where x is the time, in milliseconds you want the poll rate to be

2 Likes

Ha. I originally had the expression structure binding going and switched it once I had the polling issue. That feels a bit less cobbled, thanks!

Sam,

I am a scripting begginer, and after looking at the image of your code it is very simmilar what I am looking to do using an script (adding markers on a map, based on UDT properties/values).
Can you please share the complete code of your implementation... I am asking because the image is not showing all the code?

Thanks in advance!

1 Like