My program checks every 30 seconds if my location =< 200 meter from POI. When this is true then I want a alert message, but I want that alert message only one time. If my location is > 200 meter then nothing, but when I'm again =< 200 meter again a alert message only 1 time. Can someone please help me white this problem. Some code examples will be helpful.
1 Answer
Hi Henri
Your explanation is not very clear, but I think you want to make sure that you ONLY alert someone once until you re-enter the area after leaving it.
If this is correct, simply add a variable that says CanInform, then when you are less than 200 meters check if you CanInform, if you can then alert them, change CanInfo to false. If another even fires and you are still inside 200 meters then when you try and inform again you cannot as the CanInform is set to false. Once you go outside 200 meters set CanInform back to true.
So VERY simple example;
// place this outside of all events var boolCanInform = true; // less than 200 meters event if (boolCanInform === true) { boolCanInform === false; alert('Inside'); } // more than 200 meters event boolCanInform === true;As simple as that.
Your Answer
Think you can help? Login to answer this question!