我正试图在flutter中绘制从当前位置到另一个位置的多段线,我在网上看到的所有示例都对这部分代码没有问题。
void setPolylines() async {
List<PointLatLng> result = await polylinePoints.getRouteBetweenCoordinates(
googleAPIKey,
currentLocation.latitude,
currentLocation.longitude,
destinationLocation.latitude,
destinationLocation.longitude);
上面的代码给了我下面的错误
A value of type 'PolylineResult' can't be assigned to a variable of type 'List<PointLatLng>'.
Try changing the type of the variable, or casting the right-hand type to 'List<PointLatLng>'.
Open documentation
Too many positional arguments: 3 expected, but 5 found. Try removing the extra positional arguments, or specifying the name for named arguments. Open documentation
看起来您使用的是基于您使用的方法的flatter_polyline_points包。
查看文档,您似乎需要将getRouteBetweenCoordinates
方法的结果传递给PolylineResult
,而不是List<PointLatLng>
例如:
PolylineResult result = await polylinePoints.getRouteBetweenCoordinates(googleAPiKey,
_originLatitude, _originLongitude, _destLatitude, _destLongitude);