gpt4 book ai didi

android - 标记来自 Google Maps Directions API 响应的高速公路

转载 作者:太空狗 更新时间:2023-10-29 13:05:25 27 4
gpt4 key购买 nike

我目前正在开发一个在 Android 上使用 google maps Directions API 的项目。

当我发出任何指示请求时,我会收到类似 this one 的响应

我实际上能够解码该点以获得要到达的后续 LatLng 坐标列表。现在我需要了解两个后续 LatLng 点之间的每条路径是高速公路(您必须付费才能到达那里)还是普通街道。

我不认为有任何方法可以从这个响应中做到这一点。我可以使用任何其他参数来显示此信息吗?或者我可以使用任何其他 API 吗?

{
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "ChIJBVcXiwukOxMRaaVJcZxIGXQ",
"types" : [ "locality", "political" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJ76RLkZW8OxMRpBS0rnKK0dI",
"types" : [ "locality", "political" ]
}
],
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 40.7912565,
"lng" : 14.498954
},
"southwest" : {
"lat" : 40.7461626,
"lng" : 14.3675599
}
},
"copyrights" : "Dati mappa ©2018 Google",
"legs" : [
{
"distance" : {
"text" : "14,6 km",
"value" : 14606
},
"duration" : {
"text" : "21 min",
"value" : 1244
},
"end_address" : "80045 Pompei NA, Italia",
"end_location" : {
"lat" : 40.7461626,
"lng" : 14.498954
},
"start_address" : "80059 Torre del Greco NA, Italia",
"start_location" : {
"lat" : 40.7893898,
"lng" : 14.3675599
},
"steps" : [
{
"distance" : {
"text" : "0,3 km",
"value" : 260
},
"duration" : {
"text" : "1 min",
"value" : 71
},
"end_location" : {
"lat" : 40.7912565,
"lng" : 14.3694103
},
"html_instructions" : "Procedi in direzione \u003cb\u003enordest\u003c/b\u003e da \u003cb\u003eStrada Statale 18 Tirrena Inferiore\u003c/b\u003e/\u003cb\u003eSR18\u003c/b\u003e verso \u003cb\u003eTraversa I Vittorio Veneto\u003c/b\u003e",
"polyline" : {
"points" : "ut}wFgduvAe@c@WUKMa@]MOi@i@kCkCeAeA"
},
"start_location" : {
"lat" : 40.7893898,
"lng" : 14.3675599
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,9 km",
"value" : 932
},
"duration" : {
"text" : "3 min",
"value" : 162
},
"end_location" : {
"lat" : 40.7846057,
"lng" : 14.3756157
},
"html_instructions" : "Svolta a \u003cb\u003edestra\u003c/b\u003e per rimanere su \u003cb\u003eStrada Statale 18 Tirrena Inferiore\u003c/b\u003e/\u003cb\u003eSR18\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "k`~wFyouvA~@}AhA{AdCcDhBaCd@o@tByCnAaBt@_ALQHMRUBCPOb@Qf@Gb@EVEr@KPGTG^WFILMNMLM`AeAp@s@RWLIJGNEJETAl@GXB"
},
"start_location" : {
"lat" : 40.7912565,
"lng" : 14.3694103
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "1,0 km",
"value" : 973
},
"duration" : {
"text" : "2 min",
"value" : 123
},
"end_location" : {
"lat" : 40.7908857,
"lng" : 14.3829714
},
"html_instructions" : "Svolta a \u003cb\u003esinistra\u003c/b\u003e e prendi \u003cb\u003eVia Cavallo\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "yv|wFsvvvACOCICICGO_@w@qAKOCGCICICISmAG_@CMEMCGAE_AoAkCgDoB}Bi@o@i@c@GGEECEYg@e@{@UYY[y@eAk@m@OQUWQKMEs@NMDSBK?IAECSOa@k@]a@ECMGSISQECg@q@IG{@qAAGQ_@"
},
"start_location" : {
"lat" : 40.7846057,
"lng" : 14.3756157
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,2 km",
"value" : 202
},
"duration" : {
"text" : "1 min",
"value" : 35
},
"end_location" : {
"lat" : 40.7897602,
"lng" : 14.3848068
},
"html_instructions" : "Alla rotonda prendi la \u003cb\u003e1ª\u003c/b\u003e uscita e prendi lo svincolo \u003cb\u003eA3\u003c/b\u003e/\u003cb\u003eE45\u003c/b\u003e per \u003cb\u003eAutostrade\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eStrada a pedaggio parziale\u003c/div\u003e",
"maneuver" : "roundabout-right",
"polyline" : {
"points" : "a~}wFqdxvA@C?C?E?E?C?ETe@b@y@x@}AbA}Af@u@"
},
"start_location" : {
"lat" : 40.7908857,
"lng" : 14.3829714
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "9,9 km",
"value" : 9941
},
"duration" : {
"text" : "7 min",
"value" : 402
},
"end_location" : {
"lat" : 40.7495621,
"lng" : 14.476954
},
"html_instructions" : "Mantieni la \u003cb\u003esinistra\u003c/b\u003e al bivio, segui le indicazioni per \u003cb\u003eE45\u003c/b\u003e/\u003cb\u003eSalerno\u003c/b\u003e/\u003cb\u003eReggio C.\u003c/b\u003e ed entra in \u003cb\u003eA3\u003c/b\u003e/\u003cb\u003eE45\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eStrada a pedaggio\u003c/div\u003e",
"maneuver" : "fork-left",
"polyline" : {
"points" : "_w}wFapxvAV_@DEPQLIPIVKRGPEPCPAX?H@N@VFPDNHPHVRPPJLLRLRP\\Vv@j@bBn@|BH`@DZBX@T@X?PAN?LCXCRCRGVGPGRKVMTKRMLGHIFIDGBI@I@GAIAGAGEIEEEEGEKEKAKCI?K?K?I@K?G@KBMBGDM@??APy@dBeDTc@Tg@Vg@zEoJJUFMTa@^u@p@iAb@w@x@qAn@{@rA_B~@aAbB}A`DqCfByAJKdBuAdA_A`A}@j@s@zAuBt@iAXg@Ta@Te@HQLYNa@Rw@^yAf@sBdAiERw@p@}Bz@eDl@gCr@yCj@eC`AcELe@Je@ViAt@}Cl@aCZwATeAp@{Ch@_CpAsFr@iCt@oCb@_B|@mDLi@J[H[tA_Fl@wBFUrA{E~@gDl@wB^wA~BoIDQFSdCyIf@iBVaANi@l@gCx@aEb@kBBMh@eCDYLc@XcATs@Ng@Lc@Na@Ja@Z{AJe@H_@F]XqA^wBVyAJq@Ns@Po@n@_CRq@p@oCz@aEZqADO?CFQrA{FBIDSBKJ_@r@oClA{EZsAFWFWfA{Ev@}Dx@wD?CH[?AF[b@kBlBkIdAcFdAmE|@uDZuAHe@XyAJw@H}@HmBF_DBiD@_@?a@HyHDmEHgEDu@Bk@Fi@Fw@^cCJk@Lk@ZgArAwDPg@p@aBdBiF?A@CFOh@{An@iBH[t@qB@GFOBIJ[^cA|@aC^cAjAwCt@kBfAoCjAuC@A`AaC~C}HpAcDn@aBv@wBt@sB`AsCbBcFBEJY?AJYfAsCzAcE|AgEvBaGx@aCzB}FlDgJXs@n@gB"
},
"start_location" : {
"lat" : 40.7897602,
"lng" : 14.3848068
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,2 km",
"value" : 212
},
"duration" : {
"text" : "1 min",
"value" : 32
},
"end_location" : {
"lat" : 40.7482728,
"lng" : 14.4784155
},
"html_instructions" : "Prendi l'uscita \u003cb\u003ePompei\u003c/b\u003e verso \u003cb\u003ePompei\u003c/b\u003e/\u003cb\u003ePompei Ovest\u003c/b\u003e",
"maneuver" : "ramp-right",
"polyline" : {
"points" : "w{uwF}ojwARKBCBEL_@Vk@\\q@`@{@Rk@Pc@HQDCDCFCDCF@D@D@@@FBVN"
},
"start_location" : {
"lat" : 40.7495621,
"lng" : 14.476954
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "1,0 km",
"value" : 991
},
"duration" : {
"text" : "3 min",
"value" : 169
},
"end_location" : {
"lat" : 40.7471718,
"lng" : 14.489806
},
"html_instructions" : "Svolta a \u003cb\u003esinistra\u003c/b\u003e e prendi \u003cb\u003eStrada Statale 18 Tirrena Inferiore\u003c/b\u003e/\u003cb\u003eSR18\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "usuwFcyjwATwAPuAJw@JaAJcAPcBDc@Hk@Lm@TcA`@iBr@cDN{@j@qD?GFcAB{@IaBq@yNSiEEkABWAeA"
},
"start_location" : {
"lat" : 40.7482728,
"lng" : 14.4784155
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,5 km",
"value" : 520
},
"duration" : {
"text" : "2 min",
"value" : 102
},
"end_location" : {
"lat" : 40.74907,
"lng" : 14.4952359
},
"html_instructions" : "Alla rotonda prendi la \u003cb\u003e2ª\u003c/b\u003e uscita e prendi \u003cb\u003eVia Plinio\u003c/b\u003e",
"maneuver" : "roundabout-right",
"polyline" : {
"points" : "yluwFi`mwA@??A@A?A@??A?A?A?A?A?A?A?A?AA??A?AA??AA??AA??AA?A?A?A?A??@A?KQGCeAsCQi@kCuGMs@OaA?Cg@kEi@kEEa@"
},
"start_location" : {
"lat" : 40.7471718,
"lng" : 14.489806
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,2 km",
"value" : 198
},
"duration" : {
"text" : "1 min",
"value" : 62
},
"end_location" : {
"lat" : 40.7493801,
"lng" : 14.4975391
},
"html_instructions" : "Continua su \u003cb\u003eVia Roma\u003c/b\u003e",
"polyline" : {
"points" : "uxuwFgbnwAEW?EKu@Kw@KaAGeACa@Aa@EsB"
},
"start_location" : {
"lat" : 40.74907,
"lng" : 14.4952359
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,3 km",
"value" : 324
},
"duration" : {
"text" : "1 min",
"value" : 78
},
"end_location" : {
"lat" : 40.7466072,
"lng" : 14.4987269
},
"html_instructions" : "Svolta a \u003cb\u003edestra\u003c/b\u003e e prendi \u003cb\u003eVia Vittorio Emanuele\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "szuwFspnwAlC{@zAc@rC_ArBm@ZMZQ"
},
"start_location" : {
"lat" : 40.7493801,
"lng" : 14.4975391
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "53 m",
"value" : 53
},
"duration" : {
"text" : "1 min",
"value" : 8
},
"end_location" : {
"lat" : 40.7461626,
"lng" : 14.498954
},
"html_instructions" : "Continua su \u003cb\u003eVia Antonio Morese\u003c/b\u003e",
"polyline" : {
"points" : "iiuwFaxnwAdAc@RG"
},
"start_location" : {
"lat" : 40.7466072,
"lng" : 14.4987269
},
"travel_mode" : "DRIVING"
}
],
"traffic_speed_entry" : [],
"via_waypoint" : []
}
],
"overview_polyline" : {
"points" : "ut}wFgduvAkBeBiGkG~@}AhA{AnFeHzCiEdCaDn@y@POb@QjAMjAQf@OdA}@`CgC`@a@ZM`@Gl@GXBGYGQgAqBOWGSWwAUcAaAuA{FeHi@o@i@c@MM]m@{@uAoCaDUWQKMEs@Na@HUAYS_AmASKg@[m@u@eAyASg@@G?Ux@_Bx@}AbA}A~@uAVW^Sj@Sb@Ij@AXBh@L`@Rh@d@X`@^p@bAzCx@~CHt@Bn@EhAGf@Oh@Sj@Yh@UVSLQDQ?QCQKKMKWEm@Bi@Nc@P{@zBiEtGuMnBoD|AiCbC{CbD_DhGkFpBaBfC}BfCiDnAqBbAsBb@yAfAmExAaGlBcHnEkRfBsHpC{LzBsJhByGzBsIvJ}]rGoU~@kD|@qDjCaMR}@n@wBx@oCx@_Ex@iEb@kC`@cBbAqDp@oCz@aE`@aB~A{GhAoExB_JfA{Ev@}Dx@{Dt@eDrDoPbCcKd@{Bd@qCRkDJiIPiQN}FJuAf@{DXwAZgArAwDbAiCnB_GrDqKhEaLjEsKbJeUlBkFdDwJZ{@xJaXtD_KfE{Kn@gBRKFId@kA~@mBd@oANULGLATHVNTwA\\mCn@mGVyAv@mDbA_Fj@yDJ_C{@{QYuGBWAeA@??A@C@GEQEAC?A?MOGCeAsC}C_I]uBg@oEu@kGWmBSgCEcAEsBlC{@nFcBnC{@tB}@"
},
"summary" : "A3/E45",
"warnings" : [],
"waypoint_order" : []
}
],
"status" : "OK"
}

最佳答案

您可以设置可选参数 ...&avoid=tolls...(或 highways 或两者:avoid=tolls|highways)在 Directions Request ,例如:

https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&avoid=tolls&mode=bicycling&key=[YOUR_KEY]

在没有那种道路的情况下获得响应。

更新

来自 this Rishi Singh的答案:对于收费公路,您可以在 stepshtml_instructions 子节点中找到“toll”(或“toll road”)标签> 响应 JSON 中的节点,例如:

...
"steps": [
{
"distance": {
"text": "42.5 mi",
"value": 68323
},
"duration": {
"text": "38 mins",
"value": 2254
},
"end_location": {
"lat": 42.4352772,
"lng": -87.95487469999999
},
"html_instructions": "Merge onto <b>I-94 E</b><div style=\"font-size:0.9em\">Partial toll road</div><div style=\"font-size:0.9em\">Entering Illinois</div>",
"maneuver": "merge",
"polyline": {
...

因此,您不仅要标记收费部分,还要标记收费公路的整个“台阶”。

另外,看看 this Emad Dehnavi的答案.

更新 2

也许可以为带有“部分收费公路”标签的步骤创建“子请求”,并通过完全“收费公路”部分获得更精确的响应......或者将响应与 &avoid=tolls 结合起来并且没有那个限制并以这种方式获得收费部分。

更新 3

还有另一种解决方法:您可以使用 Google map Styled Map并设置自定义样式(例如,红色表示具有受控 channel 的道路,蓝色表示高速公路),如图所示:

Highways and Controlled-access roads

然后在道路上获得积分并使用 this 中的方法回答在程式化 map 上测试颜色以及JSON分析,可能是您更准确地确定高速公路/收费公路。

关于android - 标记来自 Google Maps Directions API 响应的高速公路,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48559126/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com