|
|
@ -461,12 +461,6 @@ class _LocationMap extends State<LocationMap> with WidgetsBindingObserver { |
|
|
|
_mapController.cleanAllMarkers(); |
|
|
|
_mapController.cleanAllMarkers(); |
|
|
|
if (polylineId != null) _mapController.removeOverlay(polylineId); |
|
|
|
if (polylineId != null) _mapController.removeOverlay(polylineId); |
|
|
|
|
|
|
|
|
|
|
|
BMFCoordinate startLocation = BMFCoordinate( |
|
|
|
|
|
|
|
coordinates.first.latitude, coordinates.first.longitude); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BMFCoordinate endLocation = |
|
|
|
|
|
|
|
BMFCoordinate(coordinates.last.latitude, coordinates.last.longitude); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// 创建polyline |
|
|
|
/// 创建polyline |
|
|
|
BMFPolyline colorsPolyline = BMFPolyline( |
|
|
|
BMFPolyline colorsPolyline = BMFPolyline( |
|
|
|
// id: polylineOptions.hashCode.toString(), |
|
|
|
// id: polylineOptions.hashCode.toString(), |
|
|
@ -486,7 +480,8 @@ class _LocationMap extends State<LocationMap> with WidgetsBindingObserver { |
|
|
|
/// 添加polyline |
|
|
|
/// 添加polyline |
|
|
|
_mapController.addPolyline(colorsPolyline); |
|
|
|
_mapController.addPolyline(colorsPolyline); |
|
|
|
var startBmfMarker = BMFMarker.icon( |
|
|
|
var startBmfMarker = BMFMarker.icon( |
|
|
|
position: startLocation, |
|
|
|
position: BMFCoordinate( |
|
|
|
|
|
|
|
coordinates.first.latitude, coordinates.first.longitude), |
|
|
|
centerOffset: BMFPoint(0.5, 0.7), |
|
|
|
centerOffset: BMFPoint(0.5, 0.7), |
|
|
|
enabled: false, |
|
|
|
enabled: false, |
|
|
|
icon: "assets/image/icon_start.png", |
|
|
|
icon: "assets/image/icon_start.png", |
|
|
@ -495,19 +490,40 @@ class _LocationMap extends State<LocationMap> with WidgetsBindingObserver { |
|
|
|
_mapController.addMarker(startBmfMarker); |
|
|
|
_mapController.addMarker(startBmfMarker); |
|
|
|
|
|
|
|
|
|
|
|
var terminalBmfMarker = BMFMarker.icon( |
|
|
|
var terminalBmfMarker = BMFMarker.icon( |
|
|
|
position: endLocation, |
|
|
|
position: BMFCoordinate( |
|
|
|
|
|
|
|
coordinates.last.latitude, coordinates.last.longitude), |
|
|
|
centerOffset: BMFPoint(0.5, 0.7), |
|
|
|
centerOffset: BMFPoint(0.5, 0.7), |
|
|
|
enabled: false, |
|
|
|
enabled: false, |
|
|
|
icon: "assets/image/icon_end.png", |
|
|
|
icon: "assets/image/icon_end.png", |
|
|
|
draggable: false, |
|
|
|
draggable: false, |
|
|
|
); |
|
|
|
); |
|
|
|
_mapController.addMarker(terminalBmfMarker); |
|
|
|
_mapController.addMarker(terminalBmfMarker); |
|
|
|
_mapController.setVisibleMapRectWithPadding( |
|
|
|
|
|
|
|
visibleMapBounds: BMFCoordinateBounds( |
|
|
|
double maxLatitude = 0, |
|
|
|
northeast: startLocation, southwest: endLocation), |
|
|
|
minLatitude = 0, |
|
|
|
animated: true, |
|
|
|
maxLongitude = 0, |
|
|
|
insets: |
|
|
|
minLongitude = 0; |
|
|
|
EdgeInsets.only(top: 500.h, bottom: 200.h, left: 200.w, right: 200.w)); |
|
|
|
coordinates.forEach((element) { |
|
|
|
|
|
|
|
if (element.latitude > maxLatitude) maxLatitude = element.latitude; |
|
|
|
|
|
|
|
if (minLatitude == 0) |
|
|
|
|
|
|
|
minLatitude = element.latitude; |
|
|
|
|
|
|
|
else if (element.latitude < minLatitude) minLatitude = element.latitude; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (element.longitude > maxLongitude) maxLongitude = element.longitude; |
|
|
|
|
|
|
|
if (minLongitude == 0) |
|
|
|
|
|
|
|
minLongitude = element.longitude; |
|
|
|
|
|
|
|
else if (element.longitude < minLongitude) |
|
|
|
|
|
|
|
minLongitude = element.longitude; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
_mapController.setVisibleMapBounds( |
|
|
|
|
|
|
|
BMFCoordinateBounds( |
|
|
|
|
|
|
|
northeast: BMFCoordinate( |
|
|
|
|
|
|
|
maxLatitude + ((maxLatitude - minLatitude) * 0.8), |
|
|
|
|
|
|
|
maxLongitude + ((maxLongitude - minLongitude) / 2)), |
|
|
|
|
|
|
|
southwest: BMFCoordinate( |
|
|
|
|
|
|
|
minLatitude - ((maxLatitude - minLatitude) * 0.2), |
|
|
|
|
|
|
|
minLongitude - ((maxLongitude - minLongitude) / 2))), |
|
|
|
|
|
|
|
true); |
|
|
|
|
|
|
|
|
|
|
|
hours = needHours == 0 ? "" : "$needHours小时"; |
|
|
|
hours = needHours == 0 ? "" : "$needHours小时"; |
|
|
|
minutes = needMinutes == 0 ? "" : "$needMinutes分钟"; |
|
|
|
minutes = needMinutes == 0 ? "" : "$needMinutes分钟"; |
|
|
|