How to use the ol/style/Fill function in ol

To help you get started, we’ve selected a few ol examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Viglino / ol-ext / src / source / Vector3D.js View on Github external
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(); });
  }
};
github SuperMap / iClient-JavaScript / src / openlayers / core / StyleUtils.js View on Github external
// 填充色 + 透明度
    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
        })
      })
    });
  }
  /**
github Viglino / ol-ext / src / source / Vector3D.js View on Github external
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(); });
github geostyler / geostyler-openlayers-parser / data / olStyles / point_simpletriangle.ts View on Github external
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;
github ghettovoice / vuelayers / src / ol-ext / style.js View on Github external
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)
  }
}
github KlausBenndorf / guide4you / src / Styling.js View on Github external
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
    }
github SuperMap / iClient-JavaScript / src / openlayers / core / StyleUtils.js View on Github external
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
      })
    })
  }
github KlausBenndorf / guide4you / src / Styling.js View on Github external
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
    }