Browse Source

路径不根据Padding属性更改,改为根据x轴和y轴的极值差计算出路径范围;

dev
huixiang_app 1 year ago
parent
commit
9583968a56
  1. 44
      lib/union/location_map_page.dart

44
lib/union/location_map_page.dart

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

Loading…
Cancel
Save