简体   繁体   中英

detect the change of direction

I am currently working on a school project in high school. Is there a way to get the types of manoeuvre (turn left or right.) in real time? Do you know if there is a function "turn left / turn right" in DirectionsRenderer? Thank you for your answers.

Currently, there is no such function. I believe you'll have to do a manual implementation to achieve this.

I would suggest first to analyze the returned response by logging it. On the returned response, there's a "maneuver" property in which the value tells what action should be performed. Some of the values were: "turn-right", "turn-left", "turn-slight-right" , etc. These values will be a big help for your project.

Here's a sample response:

    {
      "distance" : {
         "text" : "0.3 mi",
         "value" : 403
      },
      "duration" : {
         "text" : "2 mins",
         "value" : 120
      },
      "end_location" : {
         "lat" : 41.8745324,
         "lng" : -87.6292009
      },
      "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eS Dearborn St\u003c/b\u003e",
      "maneuver" : "turn-right",
      "polyline" : {
         "points" : "oir~FdbzuOdAArDE|@CpBE`AAZ?tBAH?lA?"
      },
      "start_location" : {
         "lat" : 41.878156,
         "lng" : -87.6293093
      },
      "travel_mode" : "BICYCLING"
    },

Hope it could help and goodluck on your project!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM