Confira um exemplo de uma rota com múltiplas paradas.
A Trip API suporta até 200 paradas por requisição. No exemplo abaixo, vamos roteirizar 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 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 encontra-se abaixo. As coordenadas estão no fomato polyline:
{
"id": "63ed235ce6d0947ecc99c8cc",
"clientId": "qBPERsYpGuBp9ksxA1EGncIYlVM8ULee",
"totalDistance": 109003,
"totalNominalDuration": 11225,
"averageSpeed": 26.06,
"legs": [
{
"dist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@cAW_AM{BE??_BEgABg@EWKM[IC??u@oDCSlCuIJ}@??CoN@iCCe@E]e@uAGe@MuF??l@SnAu@^[@AjAw@NONWPq@BY?]S}@a@i@QMOGe@GgA@gAF??YQSQKUI_@Ei@@[X{E^_FNsEZuEb@gIxAo^BuA?cAG_BGw@QiAe@sBuAeE??Du@ZwDZsGxAe^?eA??Hu@LsC??"
},
{
"distance": 7319,
"nominalDuration": 946,
"averageSpeed": 26.55,
"points": "hfwnCnxl{Gp@kMPyBx@_I|@eK\\kC`AeCF[Rk@dBqE??xKtE??rIeWhEyLnCeI?A??S_A[qAq@kBm@sAg@aAq@gAiDoFGUq@oFi@oFu@mEk@wB??}Ak@gDq@yCe@YKs@y@k@e@QE??\\mArI}WtDuKhD_KRa@\\_@tFeE??X_@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": 6017,
"nominalDuration": 1128,
"averageSpeed": 24.44,
"points": "heynC~ia{Gh@Bf@AVEPGXUL]Bo@GqA@SDUFQ^[ZO??^BNF??lCfBxAl@??o@VsAj@aAj@kAv@o@TYHu@J[@_AM??X\\d@p@dBrD`BlCD`@JvA?p@BJDDL???LY`@o@`A_ArGaFz@a@HIX}@Fg@IqALqD`@wAZq@Za@bAs@~CwAl@Qb@@RDz@d@RDR@d@Md@w@??|[vFxPvCJE^y@dBgCfAsAn@m@??J@BFqAxIsCxQiC`Qa@jAo@~AoCbGYv@??~F~BxHnCrBz@`@Z~FxB`IlC??wDj\\IjACr@?`ABjAJnAfBbNFl@JvB??"
},
{
"distance": 8205,
"nominalDuration": 919,
"averageSpeed": 29.11,
"points": "t||nCdme{GdBf_@?t@KfMCzF@~@DnAL~AP~@pA~EjBbGj@tBF^xBnXHnA?f@Eh@]vAiBrGKv@Eb@AxADlDFp@xEhJrBdFfCjF??bBpEPr@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@PYpBsE??v@MdNuAdEOtAB`@F`AXhFzAtEvA|Cl@pADfAHXCzK|@p@JhJdArOxA??NqACMEi@AaATqRBgKDqC??[EGhBOxR??uDC??"
},
{
"distance": 4581,
"nominalDuration": 597,
"averageSpeed": 28.91,
"points": "~ccoCtdh{GiCAkA@???iF??rDNzET??IxOGpFAV??iFk@{AMo@KYM}@u@kA]}@O??SBKDST??AdEId@w@jCaBvGeAjJq@hHqApMMp@Wv@a@~@]f@{@fAcNjRq@t@WLu@VkLhDyGfB}Bp@g@TaAn@aCpC]j@o@jASf@Sz@QnAA^CnE??NRHBtDQZ?LBj@XxAjALFRDHFr@d@\\Zn@~@\\l@d@jA`A~DxAbEt@nA~@dA??"
},
{
"distance": 1950,
"nominalDuration": 210,
"averageSpeed": 26.5,
"points": "hgaoCjhm{GbGfGvAfAXP`@PfA\\|ObE|GxBnCn@lCr@rHvBrFzArO|F??Ob@DVLPxAh@PAZMTWJo@??_E{A??Sa@??"
},
{
"distance": 8940,
"nominalDuration": 1270,
"averageSpeed": 22.67,
"points": "xycoCrmn{GwAwC??iDeA??m@hB??yCiAuDiAkL_D???g@VyAJKf@Y`@O??UW??EHE\\??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@`@{@bAkBfCyArBaEpF??UVOb@kGjDcSlLwVbNeBt@y@Jq@???kBj@}DzAeRzG}@h@mBlCiCbDaHnJ??qAmAoAiA??oClDmHbJ??wCkB??"
},
{
"distance": 2007,
"nominalDuration": 254,
"averageSpeed": 26.0,
"points": "rtynCp{u{GfC~AdBdAfDvAp@l@??G_@@eAzFiIrAsBdCkDpG{IbAsAf@k@l@g@XQ|CqAlMyEtDsAjD_@??ZFzBRv@AhAQpBeArAcA??"
},
{
"distance": 4632,
"nominalDuration": 690,
"averageSpeed": 22.8,
"points": "~l|nCtlt{GbEeDjCqB??a@{@??|JuFdCoAjDcBtDuBhEwBhBy@p@Uh@MdAMhCC`BLnAXfDhAx@\\t@^fA|@vApA??d@XlA^h@Jl@Dv@@??TQHM??UeGE}BHk@La@~@uB|@mA~@_A|@u@lAsAV{@ZsADc@A_@GWMQMIUEsA@MGc@i@KQEOAS?uBJeB??J_AJ]??Z_@NYTg@p@qCt@mF^yCZyC@s@E_@U_As@}@mAaAm@m@CUBYNe@bA}A~@oBt@iBl@kB???c@GQqB}A??MrDIT]T??gBYiIcAaWuC??Z_AVa@NB??"
},
{
"distance": 32772,
"nominalDuration": 2612,
"averageSpeed": 0.0,
"points": "bg~nC`jp{G^FUbB??sBUaB]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@OS??DpA?l@??EVBlAITID??MF]JgAFmT~@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@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