0

I was wondering if it was possible to use conditions with JSON. Let me explain, I would like to check a condition when the route indicates to turn left or right. I use mapbox as a navigation SDK.

In their technical documentation, he tells us that we can use StepManeuver object:

Example:

{
  "bearing_before": 299,
  "bearing_after": 202,
  "type": "turn",
  "modifier": "left",
  "location": [
    13.424671,
    52.508812
  ],
  "instruction": "Turn left onto Adalbertstraße"
}

What interests me is the value modifier which can be associated with "left" or "right".

So I would like to create a condition "if turn left then [...]" and "if turn right then [...]". But I do not know if this is possible and I do not know how to do it, thank you very much for your help.

Community
  • 1
  • 1
Atomike-Toxic
  • 212
  • 1
  • 4
  • 12

1 Answers1

-1

If i got your question.then simply.

if(modifier.equalas("left")
     // do left oper..
else if(modifier.equalas("right")
     // do right oper..
SRB Bans
  • 3,096
  • 1
  • 10
  • 21
  • Thank you very much, it must be that surely but in android studio it does not detect "modifier" yet I import the service "stepmaneuver" of mapbox. – Atomike-Toxic Apr 21 '18 at 13:27
  • @Atomike-Toxic `modifier` is just a String variable you will get from JSONObject.. eg:- `String modifier = yourJsonObj.getString("modifier");` – SRB Bans Apr 23 '18 at 06:37