# Map marker to change color depending on connection status

**URL:** <https://forums.losant.com/t/map-marker-to-change-color-depending-on-connection-status/3714>\
**Category:** Help\
**Tags:** dashboard\
**Created:** [April 5, 2021, 6:10pm UTC](https://forums.losant.com/t/map-marker-to-change-color-depending-on-connection-status/3714 "2021-04-05T18:10:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [April 5, 2021, 6:10pm UTC](https://forums.losant.com/t/map-marker-to-change-color-depending-on-connection-status/3714/1 "2021-04-05T18:10:45Z")

</div>

With the new “connectionStatus” information for devices available, I’m trying to display this information in the PopUP bubble for each mapped device first , but would like to be able to changed the color of the marker.

I can easily display deviceId as " {{ deviceId}}" but can I somehow display “connectionStatus” similar to how I would display a tag using {{deviceTags.[key]}} ?

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [April 5, 2021, 6:23pm UTC](https://forums.losant.com/t/map-marker-to-change-color-depending-on-connection-status/3714/3 "2021-04-05T18:23:07Z")

</div>

@Lars_Andersson our [recent platform update](https://www.losant.com/blog/platform-update-parallel-loops-scheduled-workflow-runs-instance-manager-apis) does allow for returning a list of devices based on connection status - including within the editors dashboard blocks that accept advanced queries, such as the [GPS History Block](https://docs.losant.com/dashboards/gps-history/). I assume that’s the block you’re referring to in your question.

However, those query changes did not lead to any changes to what is actually returned when fetching data for your dashboard. The same context is available per point - and thus per popup - as was before.

That said, I will make a feature request to allow dashboard builders to opt in to a fuller device object to be returned. I expect that the feature would only return the device’s _current_ connection status, not the connection status at each data point represented on the block.

Thanks for the suggestion, and I’ll keep you posted if we implement this.

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [April 5, 2021, 6:25pm UTC](https://forums.losant.com/t/map-marker-to-change-color-depending-on-connection-status/3714/4 "2021-04-05T18:25:58Z")

</div>

Great.

so as it is now I would only be able to display devices that are either connected or disconnected, not mix these on the same map ?

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [April 5, 2021, 6:27pm UTC](https://forums.losant.com/t/map-marker-to-change-color-depending-on-connection-status/3714/5 "2021-04-05T18:27:25Z")

</div>

You absolutely could mix the two; it just depends on how you build your device query within the block configuration. When returning data to use within the block, we do not take into account the connection status of the device - only whether a device matching the provided query has any state data to report within the block’s displayed timeframe.

---

<div class="post-metadata">

**Author:** ![Maria\_Lang](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@Maria\_Lang](https://forums.losant.com/u/Maria_Lang)\
**Post date:** [April 5, 2021, 8:25pm UTC](https://forums.losant.com/t/map-marker-to-change-color-depending-on-connection-status/3714/6 "2021-04-05T20:25:52Z")

</div>

@Lars_Andersson I may be able to walk you through a work around. Can you give me more information about your device and use case?

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [April 5, 2021, 8:43pm UTC](https://forums.losant.com/t/map-marker-to-change-color-depending-on-connection-status/3714/7 "2021-04-05T20:43:25Z")

</div>

It applies to multiple types of devices, but they are in the same Losant application.  
During the week or day they may go online/offline depending on the machines they operate on.  
I just though it would be nice to show a map showing location and online status based on color codes.

---

<div class="post-metadata">

**Author:** ![Maria\_Lang](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@Maria\_Lang](https://forums.losant.com/u/Maria_Lang)\
**Post date:** [April 5, 2021, 8:45pm UTC](https://forums.losant.com/t/map-marker-to-change-color-depending-on-connection-status/3714/8 "2021-04-05T20:45:53Z")

</div>

Do the devices stay relatively stationary or are they moving around? Do you currently have the location of the device set using a tag or an attribute?

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [April 5, 2021, 8:49pm UTC](https://forums.losant.com/t/map-marker-to-change-color-depending-on-connection-status/3714/9 "2021-04-05T20:49:46Z")

</div>

Stationary.  
I have the location defined in a tag.

---

<div class="post-metadata">

**Author:** ![Maria\_Lang](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@Maria\_Lang](https://forums.losant.com/u/Maria_Lang)\
**Post date:** [April 5, 2021, 9:05pm UTC](https://forums.losant.com/t/map-marker-to-change-color-depending-on-connection-status/3714/10 "2021-04-05T21:05:13Z")

</div>

Great!

If you create a boolean attribute you can set 1=connected 0=disconnected. Then using a [Device: Disconnect Trigger Node](https://docs.losant.com/workflows/triggers/on-disconnect/#device-disconnect-trigger-node) you can trigger a workflow that updates the attribute to 0 when disconnected.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/0/0d586a7756a53c5552e6da32f1f1ccaf1fd934a0.png)

To return the attribute to connected make sure you have the value set to 1 in all of your other Device: State Nodes.

---

<div class="post-metadata">

**Author:** ![Maria\_Lang](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@Maria\_Lang](https://forums.losant.com/u/Maria_Lang)\
**Post date:** [April 5, 2021, 9:10pm UTC](https://forums.losant.com/t/map-marker-to-change-color-depending-on-connection-status/3714/11 "2021-04-05T21:10:42Z")

</div>

Once you have this attribute set up you can then use the [additional attribute](https://docs.losant.com/dashboards/gps-history/#additional-attributes) feature of the GPS History block.

Select the advanced Pin Style option and you can then use handlebars to reference your attribute.

For example, if your attribute was connectionStatus and you wanted disconnected to be red and connected to be green.

{{#eq data.connectionStatus false}}  
{{colorMarker ‘#FF261B’}}  
{{else}}  
{{colorMarker ‘#8DB319’}}  
{{/eq}}

Let me know if this helps!
