Possible to have tower gps location and device gps location on the same map?

I am in the process of creating a context based dashboard and would like to display my device and the connected tower on the same map. Is that possible?

Hi @Jason_Walton, and welcome to the Losant Forums. Sorry for the later-than-usual reply but our anti-spam system picked up your message.

There are a few different approaches to get what you’re after here; you asked about displaying only one device and one tower on the map so that’s what I will describe here. Steps would be different for n devices and n towers.

Let’s start with two devices in Losant, each with a GPS attribute called “location”:

  • My Moving Device - Represents the actual piece of hardware that is moving around and occasionally reporting its location.
  • My Moving Device’s Tower - A placeholder device representing the tower that My Moving Device is currently reporting to. In the real world, this can represent any tower, not just a single one.

Your GPS History Block will display both devices; you can select them both specifically by ID. And you will choose to graph the “location” attribute.

My Moving Device’s location is straightforward; it’s the position being reported by the device itself. I’m assuming that when it reports location, the device is also sending up some kind of identifier to indicate which tower it is reporting to, which you could store in a separate device attribute on My Moving Device.

Somewhere within Losant, you will need to maintain a mapping of tower IDs to GPS locations (such as in a data table). Whenever My Moving Device reports its location, you can kick off an application workflow using a Device State Trigger. Within that workflow’s payload, you’ll have the identifier of the tower in the payload and, using a Table: Get Rows Node, can look up that tower and retrieve its fixed GPS location.

With that in hand, you can use a Device: State Node to report the “location” attribute for My Moving Device’s Tower, which then trickles down to the location of the tower as it’s displayed in your dashboard block.

The block also supports custom pins, which I’m assuming you’d want to render a different pin for the tower than for the moving device. So you would need some way of telling the tower apart from the device - say, for example with “type=tower” and “type=tracker” device tags.

Let me know if you have any questions, and again, welcome to Losant!

Apologies for the slow reaction to this response. I have created a workflow that triggers on a Device State change and is adding new tower id and their locations to a new Data Table (Having to save off lat/lon as two numbers instead of a location since Location is not a supported Table Data Type). That part is working great, and the unique key into my table is easily referenced by the incoming device state update workflow.

With your guidance, I now have a table of ever updating unique tower identifiers. Columns include tower_id, tower_lat, and tower_lon. And my device messages each come with an entry for tower_id. Now to creating a GPS History block. Ideally, I’d like to have a history block that has a single device, based on the dashboard context, that contains the start/stop of my device and the GPS location of each tower that served the device on its trip. Something like the image below.

Unfortunately data tables are not an input to the GPS History Block; only device tags and telemetry data.

You could potentially get what you are looking for using a Custom HTML Block, which does allow for device telemetry data, device metadata, and data table rows as inputs. We have a Google Maps example in our documentation that you could use as a starting point; however, it will require some modification to fit your use case, and the block is also intended for those with a web development background as it will require some custom coding.

This would also require creating your own Google Maps API Key for use in the block.