If the starting point, end point and passing point of Tencent Map's route planning are not on the road, they will not automatically adsorb to the nearby road.

path planning is done through Tencent official documents, which are written as follows
how to use:

  1. calculate the route plan from the beginning to the end through the route planning service.
    We provide the corresponding route service products on the mobile side, the web side and the server side, [retrieve SDK] or [WebService API];
  2. presents the route to your users through [Map SDK] or [JavaScript API].

so I got the return value of path planning for walking, driving and public transportation through WebService API
for example:

{
    "status":0,                                                     //
    "message":"query ok",                                           //
    "result":{                                                      //
                "routes":[{                                         //
                    "mode":"WALKING",                               //
                    "distance":38385,                               //:
                    "duration":581,                                 //:
                    "direction":"",                               //
                    "polyline":[39.915219, 116.403857,0,12,40,1180,40,1520,0,80,... ...],//
                    "steps":[
                        {                                           //,
                            "instruction":",239,",
                            "polyline_idx":[0,9],                   //0-9
                            "road_name":"",               //()
                            "dir_desc":"",                        //
                            "distance":239,                         //:
                            "act_desc":""                       //
                        },

                        ... ...

                        {                                           //
                            "instruction":"255,",
                            "polyline_idx":[1556,1567],
                            "road_name":"",
                            "dir_desc":"",
                            "distance":255,
                            "act_desc":""


            }
}

according to the instructions of the document, I need to draw the results on my map through JavaScript API, but I don"t know how to draw them, so I draw the route through the qq.maps.Polyline class. At the end of the WebService API document, it is said that if the starting point, the end point, and the passing point are not on the road, they will automatically adsorb to the nearby road
but my map does not adsorb to the road, indicating the straight link between the points. How can the thread be absorbed to a nearby road?

clipboard.png

Mar.21,2021

first need to extract the route provided by WebService API, that is, result.rotes.polyline, and then decompress to get the corresponding path coordinates. After these coordinates are generated into an array object, the path planning of the attachment effect can be realized. But as far as I can remember, this walk method doesn't seem to have a path. The compression method of the path is the difference compression. For more information, please see api example

.
Menu