Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ol_layer_Vector3D.prototype.setStyle = function(s) {
if (s instanceof ol_style_Style) this._style = s;
else this._style = new ol_style_Style();
if (!this._style.getStroke()) {
this._style.setStroke(new ol_style_Stroke({
width: 1,
color: 'red'
}));
}
if (!this._style.getFill()) {
this._style.setFill( new ol_style_Fill({ color: 'rgba(0,0,255,0.5)'}) );
}
if (!this._style.getText()) {
this._style.setText( new ol_style_Fill({
color: 'red'})
);
}
// Get the geometry
if (s && s.getGeometry()) {
var geom = s.getGeometry();
if (typeof(geom)==='function') {
this.set('geometry', geom);
} else {
this.set('geometry', function() { return geom; });
}
} else {
this.set('geometry', function(f) { return f.getGeometry(); });
}
};
// 填充色 + 透明度
let fillColor = StyleUtils.hexToRgb(parameters.fillColor);
fillColor.push(parameters.fillOpacity);
// 边框充色 + 透明度
let strokeColor = StyleUtils.hexToRgb(parameters.strokeColor);
strokeColor.push(parameters.strokeOpacity);
let fontSize = isRank ? 2 * parameters.radius + "px" : parameters.fontSize;
return new Style({
text: new Text({
text: text,
font: fontSize + " supermapol-icons",
placement: 'point',
textAlign: 'center',
fill: new FillStyle({
color: fillColor
}),
backgroundFill: new FillStyle({
color: [0, 0, 0, 0]
}),
stroke: new StrokeStyle({
width: parameters.strokeWidth || 0.000001,
color: strokeColor
})
})
});
}
/**
ol_layer_Vector3D.prototype.setStyle = function(s) {
if (s instanceof ol_style_Style) this._style = s;
else this._style = new ol_style_Style();
if (!this._style.getStroke()) {
this._style.setStroke(new ol_style_Stroke({
width: 1,
color: 'red'
}));
}
if (!this._style.getFill()) {
this._style.setFill( new ol_style_Fill({ color: 'rgba(0,0,255,0.5)'}) );
}
if (!this._style.getText()) {
this._style.setText( new ol_style_Fill({
color: 'red'})
);
}
// Get the geometry
if (s && s.getGeometry()) {
var geom = s.getGeometry();
if (typeof(geom)==='function') {
this.set('geometry', geom);
} else {
this.set('geometry', function() { return geom; });
}
} else {
this.set('geometry', function(f) { return f.getGeometry(); });
import OlStyle from 'ol/style/Style';
import OlStyleRegularshape from 'ol/style/RegularShape';
import OlStyleFill from 'ol/style/Fill';
const olSimpleTriangle = new OlStyle({
image: new OlStyleRegularshape({
points: 3,
radius: 6,
fill: new OlStyleFill({
color: '#FF0000'
})
})
});
export default olSimpleTriangle;
if (vlStyle[compiledKey] instanceof Fill) return vlStyle[compiledKey]
const fillStyle = reduce(vlStyle, (style, value, name) => {
if (keys.includes(name) === false) {
return style
}
name = lowerFirst(name.replace(new RegExp(prefixKey('fill')), ''))
if (name === 'color') {
value = normalizeColor(value)
}
style[name] = value
return style
}, {})
if (!isEmpty(fillStyle)) {
return new Fill(fillStyle)
}
}
function addFillsAndStrokes (subStyleConf) {
subStyleConf = subStyleConf || {}
let preparedOptions = copy(subStyleConf)
if (checkFor(subStyleConf, 'fill')) {
preparedOptions.fill = new Fill(mergeStyleConfigs(subStyleConf.fill, filledStyleConf.fill))
} else {
preparedOptions.fill = new Fill(filledStyleConf.fill)
}
if (checkFor(subStyleConf, 'stroke')) {
preparedOptions.stroke = new Stroke(mergeStyleConfigs(subStyleConf.stroke, filledStyleConf.stroke))
} else {
preparedOptions.stroke = new Stroke(filledStyleConf.stroke)
}
return preparedOptions
}
static toOLTextStyle(style, text) {
return new Style({
text: new Text({
font: (style.fontStyle || '') + ' ' + (style.fontWeight || '') + ' ' + (style.fontSize || '') + ' ' + style.fontFamily,
text: text,
textAlign: style.textAlign,
textBaseline: style.textBaseline,
fill: new FillStyle({
color: style.foreColor
}),
stroke: new StrokeStyle({
color: style.backColor
}),
offsetX: style.offsetX,
offsetY: style.offsetY
})
})
}
function addFillsAndStrokes (subStyleConf) {
subStyleConf = subStyleConf || {}
let preparedOptions = copy(subStyleConf)
if (checkFor(subStyleConf, 'fill')) {
preparedOptions.fill = new Fill(mergeStyleConfigs(subStyleConf.fill, filledStyleConf.fill))
} else {
preparedOptions.fill = new Fill(filledStyleConf.fill)
}
if (checkFor(subStyleConf, 'stroke')) {
preparedOptions.stroke = new Stroke(mergeStyleConfigs(subStyleConf.stroke, filledStyleConf.stroke))
} else {
preparedOptions.stroke = new Stroke(filledStyleConf.stroke)
}
return preparedOptions
}