我需要在此处地图的geoShape中使用渐变作为填充颜色。 有什么选择吗?
如果我使用这样的东西:
// init HereMap
let platform = new H.service.Platform({
'app_id': '111',
'app_code': '111-111',
useCIT: true,
useHTTPS: false
});
let defaultLayers = this.platform.createDefaultLayers();
let map = new H.Map(
this.mapElement.nativeElement,
defaultLayers.terrain.base,
{
zoom: 6,
center: { lat: 51.22172, lng: 6.77616 }
}
);
let behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(this.map));
let ui = H.ui.UI.createDefault(this.map, defaultLayers, 'de-DE');
// set geoShape style
let customStyle = {
strokeColor: 'none',
fillColor: 'linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(0,212,255,1) 100%)',
lineWidth: 10,
lineCap: 'square',
lineJoin: 'bevel'
};
// Create a rectangle and pass the custom style as an options parameter:
var rect = new H.map.Rect(new H.geo.Rect(53.5, 12.5, 51.5, 14.5),
{ style: customStyle });
// Add the rectangle to the map:
this.map.addObject(rect);
// Zoom the map to fit the rectangle:
this.map.setViewBounds(rect.getBounds());
我只得到一个黑色物体...
感谢您的帮助:)
答案 0 :(得分:0)
根据文档,请使用颜色名称或RGB格式输入fillcolor值。
var customStyle = {
strokeColor: 'black',
fillColor: 'rgba(255, 255, 255, 0.5)',
lineWidth: 10,
lineCap: 'square',
lineJoin: 'bevel'
};
**fillColor** The color with which a shape's area will be filled (ignored for polylines)
https://developer.here.com/documentation/maps/dev_guide/topics/geo-shapes.html