来自列表 LatLng 颤振飞镖的编码折线



菜鸟问题。我是飞镖/颤动的新手,但正在开发一个应用程序,我必须将List<LatLng>坐标转换为嵌套List<List<num>>。以便可以使用另一个帮助程序函数将其编码为折线。

这是我的错误:

Error: The argument type 'List<LatLng>' can't be assigned to the parameter type 'List<List<num>>'.

这是我的List<LatLng>是从List<PointLatLng>创建的地方。

final List<PointLatLng> result =
await polylineGetter.getRouteBetweenCoordinates(
apiKEY,
_curLoc.latitude,
_curLoc.longitude,
geolocation.coordinates.latitude,
geolocation.coordinates.longitude,
);
final List<LatLng> polylineCoordinates = [];
for (var point in result) {
polylineCoordinates
.add(LatLng(point.latitude, point.longitude));
}

如何将其转换为通用嵌套列表,以便从其他库馈送到此帮助程序函数中?下面是我需要用硬编码值转换它的示例。

final coords = encodePolyline([[38.5, -120.2],[40.7, -120.95],[43.252, -126.453],]);

这是我需要使用的功能

encodePolyline(List<List<num>> coordinates, {int accuracyExponent = 5}) //encodes a list of coordinates into an encoded polyline stirng

尝试了一些没有运气的事情,但不确定该怎么做。 提前感谢!

假设坐标是 列表

List<List<int>> result = coordinates.map( (data) => [ data.latitude , data.longitude ] ) ;

最新更新