我正在将map_view用于停车场应用程序。我想做的是当用户点击标记时绘制到标记的路线。
//This is where i get latlong from current location to destination
network
.get("origin=" +
"6.8740348" +
"," +
"79.8815354" +
"&destination=" +
destinationLat.toString() +
"," +
destinationLng.toString() +
"&key=AIzaSyBBC77865U0RsHg7kE2LmuROaMQTPiSW28")
.then((dynamic res) {
List<Steps> rr = res;
print("Print Res");
print(location.latitude.toString());
print(location.longitude.toString());
print(destinationLat.toString());
print(destinationLng.toString());
print("Print List");
print(rr);
directionsArray = new List();
for (final i in rr) {
directionsArray.add(i.startLocation);
directionsArray.add(i.endLocation);
print("Print i");
print(i);
print("Print ccc");
print(directionsArray);
drawLine(ccc);
}
//Drawing the polyline
mapView.addPolyline(
new Polyline("11", directionsArray, width: 15.0, color: Colors.blue));
setState(() {
count++;
print(count);
});
setState(() {});
});
在绘制一条路线后,点击另一条标记时出现错误。它不会画。我尝试使用setState,但无法正常工作。