bertagnan
Posts: 9
Joined: Mon Oct 09, 2017 11:01 am

Change icon when ignition on

Wed Jan 17, 2018 9:58 am

Hi all,
I created an event for "ignition on" and then during this event wanted to change the icon according to the ignition state.

I thus used Client script acquiring the ignition signal through the "Argument" as well explained in the blog.

Code: Select all

var quadro = Core.resolveInput('Quadro');

Core.log("Quadro:");

Core.log(quadro);


if (quadro) {
   Map.setMarkerIcon('car_yellow.png');
   Map.setMarkerColor('FF0000');
}

else

{
   Map.setMarkerIcon('car_white.png');
   Map.setMarkerColor('00FF00');

}
"Quadro" is the argument for [SIGNAL_IGNITION]

Where in the code you find "if (quadro)" I have tried every possible expression (boolean, text, integer) to try to make it work. The event is running always (start, pending, finish) as I expect the icon to be restored at the last step.


I should be making some big conceptual mistake.

Is anyone willing to help? Where I am terribly wrong? :roll:

BSO
Posts: 1
Joined: Fri Mar 23, 2018 5:29 am

Re: Change icon when ignition on

Fri Mar 23, 2018 5:36 am

Hi bertagnan,

Ignition parameter is string format and the values are 'True' or 'False'
also, please update your core plugin to latest update

Please try this, it's working for me :D :

Code: Select all

var quadro= Core.resolveInput('Quadro');

if(quadro == 'True')
{
//if ignition On, marker change color to green
  Map.setMarkerColor('00FF00');
}
else if(quadro == 'False')
{
//if ignition Off, marker change color to black
  Map.setMarkerColor('000000');
}

Return to “GpsGate for Developers”