【发布时间】:2020-09-03 04:45:33
【问题描述】:
菜鸟问题。我是 dart/flutter 的新手,但正在开发一个应用程序,我必须将 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
尝试了一些没有运气但不确定该怎么做的事情。提前致谢!
【问题讨论】: