javascript - Nativescript Google map - 更改折线颜色

标签 javascript android ios vue.js nativescript

在我的 Nativescript 应用程序中,我想更改 Google map 折线颜色,文档如下:

Line segment color in ARGB format, the same format used by Color. The default value is black (0xff000000).

我想使用这个颜色

rgb(138, 191, 95)

我尝试过但失败了:

drawRoute(encodedPolylinePoints) {
            this.mapView.removeAllPolylines();
            this.routeCordinates = decodePolyline(encodedPolylinePoints);
            this.polyline = new Polyline();
            this.routeCordinates.forEach(point =>
                this.polyline.addPoint(Position.positionFromLatLng(point.lat, point.lng))
            );
            this.polyline.visible = true;
            this.polyline.geodesic = true;
            this.polyline.width = 2;
            this.polyline.color = new Color('#8ABF5F');
            this.mapView.addPolyline(this.polyline);
        },

如何将其转换为适当的格式?

最佳答案

您可以查找十六进制转换,然后使用十六进制值,如下所示 polyline.color = new Color('#8ABF5F');

    mapView.removeAllShapes();
    // this.routeCordinates = decodePolyline(encodedPolylinePoints);
    let testPolyLine = new Polyline();        
    US_COORDINATES.map((coordinates: USCoordinate) => {
        testPolyLine.addPoint(Position.positionFromLatLng(coordinates.latitude, coordinates.longitude));
    });
    testPolyLine.visible = true;
    testPolyLine.geodesic = true;
    testPolyLine.width = 2;
    testPolyLine.color = new Color('#8ABF5F');
    mapView.addPolyline(testPolyLine);

希望这对您有所帮助!

关于javascript - Nativescript Google map - 更改折线颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59033510/

相关文章:

javascript - 服务器 worker 被注册两次

javascript - 文本区域问题

android - ContactsContract API android 中的问题

java - "UNAVAILABLE"从android客户端到python服务器的gRPC失败

ios - 如何在辅助显示中显示 web View (具有所有交互),例如苹果电视

javascript - 如何在 2 列中显示多个 html 表格

javascript - 如何调用函数,作为 "new Object",并再次作为函数调用?

ios - 检测多边形是否有相交线(领结)

SwitchPreferenceCompat 自定义布局的 Android id

objective-c - IOS MapView 标注调整大小