gpt4 book ai didi

ios - 谷歌路线不返回优化路线

转载 作者:行者123 更新时间:2023-11-29 01:19:52 25 4
gpt4 key购买 nike

我有一个应用程序,可以让用户使用起点/目的地点及其间的航路点生成路线。如果我提交的网址没有optimized:true,我会得到一条折线,该折线按照发送的顺序到达每个航路点。

如果我将optimized:true添加到查询中,那么在这种情况下,我的第二个路径点(zero_results)会出现错误,这会导致应用程序崩溃。在这两次提交中,我都发送了每个航路点的地址城市、邮政编码。

我的初始网址(已解码)如下所示:

https://maps.googleapis.com/maps/api/directions/json?origin=115 E Main St, Monrovia, IN 46157, USA&destination=115 E Main St, Monrovia, IN 46157, USA&waypoints=234 E SOUTHERN AVE INDIANAPOLIS, IN 46225|208 MEADOW DR DANVILLE, IN 46122|485 N INDIANA AVE SELLERSBURG, IN 47172|1111 RONALD REAGAN PKWY STE C1400 AVON, IN 46123|651 S CLARIZZ BLVD BLOOMINGTON, IN 47401&key=KEY GOES HERE

部分 JSON 返回:

"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "ChIJXZBHhT-WbIgRPl_LqYqD4hc",
"types" : [ "street_address" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJuZ2FWEBaa4gRuP_y0qBGYx0",
"types" : [ "premise" ]
},
{
"geocoder_status" : "OK",
"place_id" : "EiYyMDggTWVhZG93IERyLCBEYW52aWxsZSwgSU4gNDYxMjIsIFVTQQ",
"types" : [ "street_address" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJ-2zWpAhwaYgRbGCpQlasryo",
"types" : [ "street_address" ]
},
{
"geocoder_status" : "OK",
"place_id" : "EjIxMTExIFJvbmFsZCBSZWFnYW4gUGt3eSBjMTQwMCwgQXZvbiwgSU4gNDYxMjMsIFVTQQ",
"types" : [ "subpremise" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJV8KIRiNkbIgRZVxX1emoBQU",
"types" : [ "premise" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJXZBHhT-WbIgRPl_LqYqD4hc",
"types" : [ "street_address" ]
}
],

我的优化网址如下所示:

https://maps.googleapis.com/maps/api/directions/json?origin=115 E Main St, Monrovia, IN 46157, USA&destination=115 E Main St, Monrovia, IN 46157, USA&waypoints=optimized:true|234 E SOUTHERN AVE INDIANAPOLIS, IN 46225|208 MEADOW DR DANVILLE, IN 46122|485 N INDIANA AVE SELLERSBURG, IN 47172|1111 RONALD REAGAN PKWY STE C1400 AVON, IN 46123|651 S CLARIZZ BLVD BLOOMINGTON, IN 47401&key=KEY GOES HERE

完整的 JSON:

{
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "ChIJXZBHhT-WbIgRPl_LqYqD4hc",
"types" : [ "street_address" ]
},
{
"geocoder_status" : "ZERO_RESULTS"
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJuZ2FWEBaa4gRuP_y0qBGYx0",
"types" : [ "premise" ]
},
{
"geocoder_status" : "OK",
"place_id" : "EiYyMDggTWVhZG93IERyLCBEYW52aWxsZSwgSU4gNDYxMjIsIFVTQQ",
"types" : [ "street_address" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJ-2zWpAhwaYgRbGCpQlasryo",
"types" : [ "street_address" ]
},
{
"geocoder_status" : "OK",
"place_id" : "EjIxMTExIFJvbmFsZCBSZWFnYW4gUGt3eSBjMTQwMCwgQXZvbiwgSU4gNDYxMjMsIFVTQQ",
"types" : [ "subpremise" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJV8KIRiNkbIgRZVxX1emoBQU",
"types" : [ "premise" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJXZBHhT-WbIgRPl_LqYqD4hc",
"types" : [ "street_address" ]
}
],
"routes" : [],
"status" : "NOT_FOUND"
}

我不太确定我在这里做错了什么。

最佳答案

您应该传递 optimize:true 而不是 optimized:true

这是我比较您提供的 2 个网址时的工作网址。

https://maps.googleapis.com/maps/api/directions/json?origin=115%20E%20Main%20St,%20Monrovia,%20IN%2046157,%20USA&destination=115%20E%20Main%20St,%20Monrovia,%20IN%2046157,%20USA&waypoints=optimize:true|234%20E%20SOUTHERN%20AVE%20INDIANAPOLIS,%20IN%2046225|208%20MEADOW%20DR%20DANVILLE,%20IN%2046122|485%20N%20INDIANA%20AVE%20SELLERSBURG,%20IN%2047172|1111%20RONALD%20REAGAN%20PKWY%20STE%20C1400%20AVON,%20IN%2046123|651%20S%20CLARIZZ%20BLVD%20BLOOMINGTON,%20IN%2047401

关于ios - 谷歌路线不返回优化路线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34748855/

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