在我的 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/