Change GPS Marker Color Based on Attribute

Can the GPS marker color be changed (red would be fine) based on an attribute value? I have 600 devices and one of the atrributes is something like “motor hours used”. I would like to see a red marker for all devices over a certain amount of hours (my dashboard map shows all 600 devices globally). Thx

Hi @David_MacKenzie,

Yes, you can modify the color of the GPS based on the conditions of a given attribute. You’re going to want to use Conditional Block Helpers, which had a really nice write up as a Losant tip:

In your GPS History block, first, you’ll want to configure additional attributes along with the GPS coordinates:

Then, in your Point Display Configuration, under Pin Style, select ‘Advanced’ and using the icon template area input your code using Handlebars and the Conditional Block helpers to set the logic for determining pin color. You’ll want to use the {{#gt}} helper to set the conditional logic. I built up a test application based around the specifics you stated above, and was able to get the following code to modify the color of my GPS pin correctly, where 1000 is used as the threshold for the conditional:

{{#if isLastPoint}}
{{#gt data.motorHoursUsed 1000}}
{{colorMarker '#8db319'}}
{{else}}
{{colorMarker '#ff261b'}}
{{/gt}}
{{/if}}

Let me know if you have any other questions.

Thanks,
@Aidan_Zebertavage

Perfect. By the looks of it I can make multiple ranges and use any color.

That is correct. You can use any hex color string and I would be sure to reference our Conditional Block Helper docs to understand what expressions are supported.

Thanks,
@Aidan_Zebertavage