gpt4 book ai didi

flutter - 如何将折线拟合到Google map 抖动中的街道曲线?

转载 作者:行者123 更新时间:2023-12-03 03:40:16 25 4
gpt4 key购买 nike

如何将折线拟合到Google map 抖动中的街道曲线?

我确实在google_maps_flutter中与Polylines一起玩了2个月,对此我有疑问:

  • 折线不遵循街道曲线或高速公路。
  • 折线具有OnTap回调,但是在多折线上,我无法获得任何ID或属性以区分我所点击的识别对象。

  • 有人可以帮我吗?

    我是Flutter的新手,正在使用Google的Directions API。也许不是解决此问题的正确API。

    我需要该多段线遵循街道曲线。

    Polylines in google_maps_flutter

    P.S:对不起,如果我的代码让您大失所望!

    google_maps_flutter widget:


    GoogleMap(
    onMapCreated: (controller) {
    _mapController = controller;
    },
    initialCameraPosition: CameraPosition(
    target: getCurrentLocation(),
    zoom: 15,
    ),
    mapType: _currentMapType,
    myLocationEnabled: true,
    myLocationButtonEnabled: false,
    compassEnabled: true,
    rotateGesturesEnabled: true,
    markers: _markers,
    polylines: _polyline,
    )

    Set state to show the polyline and markers:


    setState(
    () {
    _markers.clear();
    for (var point in itinerary) {
    _markers.add(
    Marker(
    markerId: MarkerId("stop ${point.latitude}"),
    position: LatLng(point.latitude, point.longitude),
    infoWindow: InfoWindow(title: point.address),
    ),
    );
    }

    _polyline.clear();
    _polyline.add(
    flutter.Polyline(
    polylineId: PolylineId("route"),
    points: ccc,
    width: 8,
    color: Colors.red,
    geodesic: true,
    jointType: JointType.round,
    ),
    );
    _mapController.animateCamera(
    CameraUpdate.newLatLngZoom(
    LatLng(origin.lat, origin.lng), 13.0),
    );
    },
    );

    Google Directions API Call:


    GoogleMapsDirections(apiKey: apiKey).directions(origin, destination, waypoints: itinerary, ).then((DirectionsResponse response) { return response }

    最佳答案

    我从Github成员那里得到了一些建议,告诉我尝试SnapToRoad,现在我获得了有关路线的更多详细信息,但高速公路仍然是直升机的旅行路线

    一个简单的GET到https://roads.googleapis.com/v1/snapToRoads和API_KEy以及我之前的折线的一些要点都有帮助。

    这是SnapToRoad的链接

    关于flutter - 如何将折线拟合到Google map 抖动中的街道曲线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57080929/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com