How to use the @terrestris/ol-util/dist/MapUtil/MapUtil.getLayerByName function in @terrestris/ol-util

To help you get started, we’ve selected a few @terrestris/ol-util 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 terrestris / react-geo / src / Button / DigitizeButton / DigitizeButton.tsx View on Github external
createDrawInteraction = pressed => {
    const {
      drawType,
      map,
      onDrawEnd,
      onDrawStart,
      digitizeLayerName,
      drawInteractionConfig
    } = this.props;

    let geometryFunction;
    let type = drawType;

    // check whether the digitizeLayer is in map and set it from state if not
    let digitizeLayer = MapUtil.getLayerByName(map, digitizeLayerName);
    if (!digitizeLayer) {
      map.addLayer(this.state.digitizeLayer);
    }

    if (drawType === DigitizeButton.RECTANGLE_DRAW_TYPE) {
      geometryFunction = createBox();
      type = DigitizeButton.CIRCLE_DRAW_TYPE as DrawType;
    } else if (drawType === DigitizeButton.TEXT_DRAW_TYPE) {
      type = DigitizeButton.POINT_DRAW_TYPE as DrawType;
      this._digitizeFeatures.on('add', this.handleTextAdding);
    }

    const drawInteraction = new OlInteractionDraw({
      source: this.state.digitizeLayer.getSource(),
      type: type,
      geometryFunction: geometryFunction,
github terrestris / react-geo / src / Grid / AgFeatureGrid / AgFeatureGrid.tsx View on Github external
initVectorLayer = map => {
    const {
      features,
      featureStyle,
      layerName
    } = this.props;

    if (!(map instanceof OlMap)) {
      return;
    }

    if (MapUtil.getLayerByName(map, layerName)) {
      return;
    }

    const source = new OlSourceVector({
      features: features
    });

    const layer = new OlLayerVector({
      name: layerName,
      source: source,
      style: featureStyle
    });

    map.addLayer(layer);

    this._source = source;
github terrestris / react-geo / src / Button / MeasureButton / MeasureButton.tsx View on Github external
createMeasureLayer() {
    const {
      measureLayerName,
      fillColor,
      strokeColor,
      map
    } = this.props;

    let measureLayer = MapUtil.getLayerByName(map, measureLayerName);

    if (!measureLayer) {
      measureLayer = new OlLayerVector({
        name: measureLayerName,
        source: new OlSourceVector({
          features: new OlCollection()
        }),
        style: new OlStyleStyle({
          fill: new OlStyleFill({
            color: fillColor
          }),
          stroke: new OlStyleStroke({
            color: strokeColor,
            width: 2
          }),
          image: new OlStyleCircle({
github terrestris / react-geo / src / Grid / FeatureGrid / FeatureGrid.tsx View on Github external
initVectorLayer = map => {
    const {
      features,
      featureStyle,
      layerName
    } = this.props;

    if (!(map instanceof OlMap)) {
      return;
    }

    if (MapUtil.getLayerByName(map, layerName)) {
      return;
    }

    const source = new OlSourceVector({
      features: features
    });

    const layer = new OlLayerVector({
      name: layerName,
      source: source,
      style: featureStyle
    });

    map.addLayer(layer);

    this._source = source;
github terrestris / react-geo / src / Button / DigitizeButton / DigitizeButton.spec.tsx View on Github external
it ('creates a digitize vector layer, adds this to the map and assigns its value to state', () => {
        let digitizeLayer = MapUtil.getLayerByName(map, 'react-geo_digitize');

        expect(digitizeLayer).toBeUndefined();
        const wrapper = setupWrapper();

        digitizeLayer = MapUtil.getLayerByName(map, 'react-geo_digitize');
        expect(digitizeLayer).toBeDefined();
        expect(wrapper.instance()._digitizeLayer).toBe(digitizeLayer);
      });
    });
github terrestris / react-geo / src / Button / DigitizeButton / DigitizeButton.tsx View on Github external
createDigitizeLayer = () => {
    const {
      digitizeLayerName,
      map
    } = this.props;
    let digitizeLayer = MapUtil.getLayerByName(map, digitizeLayerName);
    if (!digitizeLayer) {
      digitizeLayer = new OlLayerVector({
        name: digitizeLayerName,
        source: new OlSourceVector({
          features: new OlCollection(),
        })
      });
      map.addLayer(digitizeLayer);
    }
    digitizeLayer.setStyle(this.getDigitizeStyleFunction);
    this.setState({digitizeLayer});
  }
github terrestris / react-geo / src / Button / DigitizeButton / DigitizeButton.spec.tsx View on Github external
it ('creates a digitize vector layer, adds this to the map and assigns its value to state', () => {
        let digitizeLayer = MapUtil.getLayerByName(map, 'react-geo_digitize');

        expect(digitizeLayer).toBeUndefined();
        const wrapper = setupWrapper();

        digitizeLayer = MapUtil.getLayerByName(map, 'react-geo_digitize');
        expect(digitizeLayer).toBeDefined();
        expect(wrapper.instance()._digitizeLayer).toBe(digitizeLayer);
      });
    });