提问人: 提问时间:12/9/2022 更新时间:12/9/2022 访问量:31
如何从这里地图根据 wse api 对列表进行排序
how can I sort a list according to wse api from here map
问:
我正在后端 API 的 listView.builder 中显示带有时间的订单列表,但我需要从这里地图从 WSE API 的序列基础上对该列表进行排序,并希望显示与 mylist 互连的时间,这是我的模型List<Order> allOrderList;
`
class Order {
Order({
this.id,
this.fname,
this.lname,
this.streetAddress,
this.city,
this.state,
this.zip,
this.phone,
this.orderId,
this.storeId,
this.statusKey,
this.isBad,
this.Lat,
this.Lng,
});
dynamic id;
dynamic fname;
dynamic lname;
dynamic streetAddress;
dynamic city;
dynamic state;
int? zip;
dynamic phone;
dynamic orderId;
dynamic storeId;
dynamic Lat;
dynamic Lng;
factory Order.fromJson(Map<String, dynamic> json) => Order(
id: json["_id"],
fname: json["fname"],
lname: json["lname"],
streetAddress: json["street_address"],
city: json["city"],
state: json["state"],
zip: json["zip"],
phone: json["phone"],
orderId: json["order_id"],
storeId: json["store_id"],
totalBoxes: json["total_boxes"],
Lat: json["lat"].toDouble(),
Lng: json["lng"].toDouble(),
);
Map<String, dynamic> toJson() => {
"_id": id,
"fname": fname,
"lname": lname,
"street_address": streetAddress,
"city": city,
"state": state,
"zip": zip,
"phone": phone,
"order_id": orderId,
"store_id": storeId,
"lat": Lat,
"lng": Lng,
};
}
这是 WSE 地图 API 的示例
`
{
"results": [{
"waypoints": [{
"id": "WiesbadenCentralStation",
"lat": 50.0715,
"lng": 8.2434,
"sequence": 0,
"estimatedArrival": null,
"estimatedDeparture": "2014-12-09T09:30:00+01:00",
"fulfilledConstraints": []
},
{
"id": "FranfurtCentralStation",
"lat": 50.1073,
"lng": 8.6647,
"sequence": 1,
"estimatedArrival": null,
"estimatedDeparture": "2014-12-09T10:01:02+01:00",
"fulfilledConstraints": []
},
{
"id": "HanauCentralStation",
"lat": 50.1218,
"lng": 8.9298,
"sequence": 2,
"estimatedArrival": null,
"estimatedDeparture": "2014-12-09T10:30:43+01:00",
"fulfilledConstraints": []
},
{
"id": "FrankfurtAirport",
"lat": 50.0505,
"lng": 8.5698,
"sequence": 3,
"estimatedArrival": null,
"estimatedDeparture": "2014-12-09T10:56:10+01:00",
"fulfilledConstraints": []
},
{
"id": "DarmstadtCentralStation",
"lat": 49.8728,
"lng": 8.6326,
"sequence": 4,
"estimatedArrival": null,
"estimatedDeparture": "2014-12-09T11:16:55+01:00",
"fulfilledConstraints": []
},
{
"id": "MainzCentralStation",
"lat": 50.0021,
"lng": 8.259,
"sequence": 5,
"estimatedArrival": null,
"estimatedDeparture": null,
"fulfilledConstraints": []
}],
"distance": "169262",
"time": "8362",
"interconnections": [{
"fromWaypoint": "WiesbadenCentralStation",
"toWaypoint": "FranfurtCentralStation",
"distance": 36461.0,
"time": 1862.0
},
{
"fromWaypoint": "FranfurtCentralStation",
"toWaypoint": "HanauCentralStation",
"distance": 34485.0,
"time": 1781.0
},
{
"fromWaypoint": "HanauCentralStation",
"toWaypoint": "FrankfurtAirport",
"distance": 33489.0,
"time": 1527.0
},
{
"fromWaypoint": "FrankfurtAirport",
"toWaypoint": "DarmstadtCentralStation",
"distance": 26905.0,
"time": 1245.0
},
{
"fromWaypoint": "DarmstadtCentralStation",
"toWaypoint": "MainzCentralStation",
"distance": 37922.0,
"time": 1947.0
}],
"description": "Targeted best time; with improvement for traffic"
}],
"8.1.11s": [],
"processingTimeDesc": "1345ms",
"responseCode": "200",
"warnings": null,
"requestId": null
}
` WSE API 中的 ID 是我的街道地址,我通过 WSE URL 发送,如 https://wps.hereapi.com/2/findsequence.json?app_id=my_app_id&app_code=myapp_code&start=Starting%20Location;37.785834,-122.406417&destination1=Ss%20Br0;37.35507,-82.81066&destination2=Ff%20John%20A%20Santore%20Way1;40.63348,-74.1043&destination3=Gorlitz%20Ct2;41.34471,-74.16784&improveFor=distance&mode=fastest;car;traffic:disabled;
我确实尝试了很多解决方案,但没有任何效果。
答: 暂无答案
下一个:使用 SQL 序列
评论