Flutter-折线不在可用屏幕尺寸内绘制线

问题描述 投票:0回答:1

如何在可用的屏幕尺寸内获取折线?

我正在使用Flutter Goolge Map PluginGoogle Map Polyline插件

Polyline drawing outside screensize

google-maps flutter polyline google-polyline
1个回答
0
投票

首先添加的折线放置错误。您可以按照我的回答正确生成:https://stackoverflow.com/a/58831792/7910735

对于您的问题,应在放置折线后立即使用CameraUpdate.newLatLngBounds()

有点类似于此

void animateCameraForOD() {
    mapController.animateCamera(
      CameraUpdate.newLatLngBounds(
          LatLngBounds(
              northeast: pickupPosition, southwest: destinationPosition),
          100),
    );
  }

这还将使您的两个LatLng都被缩小到具有填充的给定范围内。

请记住要检查如果此条件为真时可能会出现的某些例外

[southwest.latitude <= northeast.latitude您必须检查并进行相应的切换]

© www.soinside.com 2019 - 2024. All rights reserved.