1

我正在通过 nativescript + vuejs 开发一个使用google maps sdk的应用程序。该应用程序的主要行为包括在两个地理点之间绘制路线。

我想知道,我怎样才能用渐变绘制那条折线?

重新渲染折线的函数:

async drawRoute(mapView, encodedPolylinePoints) {
    mapView.removeAllPolylines();

    let routeCordinates = decodePolyline(encodedPolylinePoints);
    let polyline = new Polyline();

    await Promise.all(routeCordinates.map(point =>
        polyline.addPoint(Position.positionFromLatLng(point.lat, point.lng))
    ));

    polyline.visible = true;
    polyline.geodesic = true;
    polyline.width = 20;
    // polyline.color = new Color('#f8006c'); <= the start gradient color
    polyline.color = new Color('#f8b244'); // <= the end gradient color

    mapView.addPolyline(polyline);
}

谢谢!

4

0 回答 0