google maps static map polyline passing through lakes, river, mountains

后端 未结 2 1902
小鲜肉
小鲜肉 2020-12-12 07:32

My program uses google maps directions for web Services to find a route between two points. The result is parsed and stored in variable.
This variable is then used to co

2条回答
  •  感情败类
    2020-12-12 08:30

    You need to include the polyline path between each step's start and end points (it is an encoded polyline).

    From the directions web service response:

     "steps" : [
        {
           "distance" : {
              "text" : "0.3 km",
              "value" : 335
           },
           "duration" : {
              "text" : "1 min",
              "value" : 52
           },
           "end_location" : {
              "lat" : -22.9772355,
              "lng" : -43.23076390000001
           },
           "html_instructions" : "Head \u003cb\u003enortheast\u003c/b\u003e on \u003cb\u003eR. Marquês de São Vicente\u003c/b\u003e",
           "polyline" : {
              "points" : "r}fkCna{fGyBaDMSMSOUMUCMAOOgAEe@Co@?o@?YAWEk@?G"
           },
           "start_location" : {
              "lat" : -22.9783362,
              "lng" : -43.2336781
           },
           "travel_mode" : "DRIVING"
         },
         // ...
    

    Including all the step polylines (and encoding the polyline) works for me

    jsfiddle creating a URL for the static map from the web service response

提交回复
热议问题