Exemplo 2 – Rota com múltiplas paradas
No exemplo abaixo, vamos gerar uma rota com 10 pontos de parada intermediários, além dos pontos de origem e destino. Todos os pontos são declarados no parâmetro points
.
{ "calculationMode": "THE_FASTEST", "points": [ { "latitude": -23.508596, "longitude": -46.841628, "siteId": "DEPOSITO01" }, { "latitude": -23.553309, "longitude": -46.627801, "siteId": "MERCADO02GLICERIO" }, { "latitude": -23.553322, "longitude": -46.601216, "siteId": "MERCADO01MOOCA" }, { "latitude": -23.563248, "longitude": -46.542555, "siteId": "MERCADO07VLFORMOSA" }, { "latitude": -23.582342, "longitude": -46.563542, "siteId": "MERCADO08VLPRUDENTE" }, { "latitude": -23.614230, "longitude": -46.577557, "siteId": "MERCADO10SCAETANO" }, { "latitude": -23.604505, "longitude": -46.603767, "siteId": "MERCADO06IPIRANGA" }, { "latitude": -23.617710, "longitude": -46.609707, "siteId": "MERCADO09TANCNEVES" }, { "latitude": -23.565705, "longitude": -46.647747, "siteId": "MERCADO03BRIGADEIRO" }, { "latitude": -23.579845, "longitude": -46.640287, "siteId": "MERCADO04VMARIANA" }, { "latitude": -23.589185, "longitude": -46.619167, "siteId": "MERCADO05RICARDOJAFET" }, { "latitude": -23.508596, "longitude": -46.841628, "siteId": "DEPOSITO01VOLTA" } ] }
O resultado pode ser conferido no mapa abaixo:
Na resposta, será retornado um array de objetos chamado legs
. Cada objeto presente em legs
representa um trecho da rota e irá conter os dados referentes apenas a esse trecho. Sendo a primeira leg
correspondente à rota do primeiro ao segundo ponto, a segunda leg
corresponde à rota entre o segundo e o terceiro ponto e assim por diante.
A resposta completa pode ser conferida abaixo, com as coordenadas codificadas como polyline
.
{ "id": "657b93dcbb432a18819d647a", "clientId": "qBPERsYpGuBp9ksxA1EGncIYlVM8ULee", "totalDistance": 109012, "totalNominalDuration": 11316, "averageSpeed": 29.94, "legs": [ { "distance": 27158, "nominalDuration": 1935, "averageSpeed": 48.48, "points": "vonnCjv{|GvGAB}G?mMLsEFqALgAZ}BXs@x@{AVs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@@[X{E^_FNsEZuEb@gIxAo^BuA?cAG_BGw@QiAe@sBuAeEDu@ZwDZsGxAe^?eAHu@LsC" }, { "distance": 7319, "nominalDuration": 946, "averageSpeed": 26.55, "points": "hfwnCnxl{Gp@kMPyBx@_I|@eK\\kC`AeCF[Rk@dBqExKtErIeWhEyLnCeI?AS_A[qAq@kBm@sAg@aAq@gAiDoFGUq@oFi@oFu@mEk@wB}Ak@gDq@yCe@YKs@y@k@e@SGrJiZtDuKhD_KRa@\\_@tFeEX_@LKNITYDKD_@@w@Fw@fFwN|DmL^mALw@De@@w@GmB_@uCYmAmAwHGq@Ac@Be@Fq@Le@\\y@R]nC{DZk@Ne@FYBy@Ee@I_@O_@m@o@oAaA[YQSO]Oo@Cu@DaALs@V{@^e@zEgF`@i@\\k@Vw@Pw@jA{Id@sALY`@o@COEKoAwAeAaB[k@eBsDe@q@mAsA?G\\A" }, { "distance": 6016, "nominalDuration": 1128, "averageSpeed": 24.44, "points": "heynC~ia{Gh@Bf@AVEPGXUL]Bo@GqA@SDUFQ^[ZO^BNFlCfBxAl@o@VsAj@aAj@kAv@o@TYHu@J[@_AMX\\d@p@dBrD`BlCD`@JvA?p@BJDDL?LY`@o@t@s@~GmFz@a@HIX}@Fg@EoAHsD`@wAZq@Za@bAs@~CwAl@Qb@@RDz@d@RDR@d@Md@w@|[vFxPvCJE^y@dBgCfAsAn@m@J@BFqAxIsCxQiC`Qa@jAo@~AoCbGYv@~F~BxHnCrBz@`@Z~FxB`IlCwDj\\IjACr@?`ABjAJnAfBbNFl@JvB" }, { "distance": 8204, "nominalDuration": 919, "averageSpeed": 29.11, "points": "t||nCdme{GdBf_@?t@KfMCzF@~@DnAL~AP~@pA~EjBbGj@tBF^xBnXHnA?f@Eh@]vAiBrGKv@Eb@AxADlDFp@xEhJrBdFfCjFbBpEPr@RrAj@|EHNN@b@C^ILUF[]sDCgABk@Fu@Ls@Tw@Pa@NUpBgCLWbEkDbN{Kd@e@`@k@R_@Zq@v@sBh@{@j@o@vCgCtFkE`LcJd@Y^OpCeAx@g@n@u@PYpBsEv@MdNuAdEOtAB`@F`AXhFzAtEvA|Cl@pADfAHXCbHj@zGp@vFp@rOxAJo@Ba@IgAAq@V_Z@cFDgA[EGhBOxRuDA" }, { "distance": 4581, "nominalDuration": 597, "averageSpeed": 26.6, "points": "~ccoCvdh{GuEA?iFrDNzETIxOGpFAViFk@{AMo@KYM}@u@]OkB]QBKBUVAdEiCvJYpAeAjJq@hHqApMMp@Wv@a@~@]f@{@fAcNjRq@t@WLu@VkLhDyGfB}Bp@g@TaAn@aCpC]j@o@jASf@Sz@QnAA^CnENRHBtDQZ?LBj@XxAjALFRD|@l@\\Zn@~@\\l@d@jA`A~DxAbEt@nA~@dA" }, { "distance": 1949, "nominalDuration": 210, "averageSpeed": 26.5, "points": "hgaoCjhm{GbGfGvAfAXP`@PfA\\|ObE|GxBnCn@lCr@rHvBrFzArO|FOb@DVLPxAh@PAZMTWJo@_E{ASa@" }, { "distance": 8939, "nominalDuration": 1270, "averageSpeed": 22.67, "points": "xycoCrmn{GwAwCiDeAm@hByCiAuDiAkL_D?g@VyAJKf@Y`@OUWEHE\\g@XKJ[f@mAdCY^}@hAm@d@u@P}AAwBGo@RMLo@dDq@hCIbE@j@PvABh@Ad@Kh@IZMRw@pA_AxA_@h@KHgA^i@HkWvBcFh@cD^q@NqA`@}FpBy@VcA`@[FU?YGgAo@i@Os@Eo@@]DcANw@Ro@Xa@VW`@[z@S^YNk@Hc@JYNGHEJCRATF|@Cf@U`Ak@hAe@n@{ApBy@z@WPi@Po@?{BS[?g@FS@@dBFl@f@fDPl@`@l@tCjCtBhBl@l@lA`Ar@|@T~@D^Ar@{@rHu@lFq@pCUf@OX[^{@t@kClBUTW\\_BlC}@bAqCpCi@\\[L_@BeCY{DY_@?c@Pe@`@gApA_BxByArBwEhGOb@kGjDcSlLgWlNuAj@y@Jq@?kBj@}DzA_RxGcAj@mBlCiCbDaHnJqAmAoAiAeDfEwGhIwCkB" }, { "distance": 2007, "nominalDuration": 254, "averageSpeed": 26.0, "points": "rtynCp{u{GvCjBtAx@fDvAp@l@GU@oAzFiIrAsBdCkDpG{IbAsAf@k@l@g@^UvCmA`MsEzDyApD_@ZFzBRv@AhAQpBeArAcA" }, { "distance": 4577, "nominalDuration": 720, "averageSpeed": 22.8, "points": "~l|nCtlt{GbEeDjCqBa@{@|JuFdCoAjDcBtDuBhEwBhBy@p@Uh@MdAMhCClAHRBbB`@rC`Ax@\\t@^fA|@vApAd@X^LvA\\l@Dv@@TQHMUeGE}BHk@La@~@uB|@mA~@_A|@u@lAsAV{@ZsADc@A_@GWMQMIUEsA@MGc@i@KQEOAiCJeBJ_AJ]Z_@NYTg@p@qCt@mF^yCZyC@s@E_@U_As@}@mAaAm@m@CUBYNe@bA}A~@oBt@iBl@kB?c@GQqB}AMrDIT]TgBYiIcAqQsBEU?QFGEYa@QEKKMo@i@" }, { "distance": 32826, "nominalDuration": 2642, "averageSpeed": 48.35, "points": "fg~nC`ip{Gn@h@JLDJG?EFGPAFZVa@RqC[aB]iD}@qCoAuEkC}DgBc@Wm@g@a@c@]q@_@mAg@aFe@iAW]i@c@q@[w@g@s@[gDiBiAy@gIkGa@o@g@i@_Aw@y@k@w@u@e@m@]w@GOq@sDSe@OSDpA?l@EV?xAGHc@RwALmT~@oOn@aYfAoG^kALkB\\Q@QEQSm@aA_Q~Hu@b@qB|AoAnAg@j@iAdBm@nAa@bAg@`BuEzSwBbKa@~Ac@xAc@hAk@jAg@`Am@~@u@`AaAjA{ArAaBjAsAz@s@Zo@RiBR_A?[CyGdCoAn@qDzAaBbA_EtBkAb@uBn@mB^oCZmAJkDHkBE_Eg@g@KcAYyCgAmPyFiGsBeIwCuC}@YGmBWk@CkBA]@q@HwA^kMxF_YfLqDpAYPIJOZm@dBiC~E{Tj^]f@_@`@oAdA_IbG[Ze@n@OXMh@IhAQvIItD@d@DXYhDyAdUSvDYlGi@jHk@~FDf@k@xL]pF]hE@d@UpC_@lG{AtVI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