How to use the ngeo/GeometryType.js.LINE_STRING function in ngeo

To help you get started, we’ve selected a few ngeo 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 camptocamp / ngeo / contribs / gmf / src / drawing / drawFeatureComponent.js View on Github external
// show contextual menu when clicking on certain types of features
    if (feature) {

      this.closeMenu_();

      /** @type {import('ngeo/Menu').MenuActionOptions[]} */
      let actions = [];
      const resolution = this.map.getView().getResolution();
      if (resolution === undefined) {
        throw new Error('Missing resolution');
      }
      const vertexInfo = this.featureHelper_.getVertexInfoAtCoordinate(feature, coordinate, resolution);
      if (!vertexInfo) {
        const type = this.featureHelper_.getType(feature);
        if (type == ngeoGeometryType.CIRCLE ||
            type == ngeoGeometryType.LINE_STRING ||
            type == ngeoGeometryType.POLYGON ||
            type == ngeoGeometryType.RECTANGLE) {
          actions = actions.concat([{
            cls: 'fas fa-arrows-alt',
            label: gettextCatalog.getString('Move'),
            name: 'move'
          }, {
            cls: 'fas fa-undo fa-flip-horizontal',
            label: gettextCatalog.getString('Rotate'),
            name: 'rotate'
          }]);
        }
      }

      actions = actions.concat([{
        cls: 'fa fa-trash',
github camptocamp / ngeo / contribs / gmf / src / editing / editFeatureComponent.js View on Github external
if (feature instanceof olFeature) {
      const resolutions = this.map.getView().getResolution();
      if (!resolutions) {
        throw new Error('Missing resolutions');
      }
      const vertexInfo = this.ngeoFeatureHelper_.getVertexInfoAtCoordinate(
        feature, coordinate, resolutions);
      if (vertexInfo) {
        this.vertexInfo_ = vertexInfo;
        this.menuVertex_.open(coordinate);
      } else {
        const type = this.ngeoFeatureHelper_.getType(feature);
        if (
          type === ngeoGeometryType.POLYGON ||
          type === ngeoGeometryType.MULTI_POLYGON ||
          type === ngeoGeometryType.LINE_STRING ||
          type === ngeoGeometryType.MULTI_LINE_STRING
        ) {
          this.menu_.open(coordinate);
        }
      }

      evt.preventDefault();
      evt.stopPropagation();
    }
  }
};
github camptocamp / ngeo / examples / createfeature.js View on Github external
function MainController(ngeoToolActivateMgr) {

  /**
   * @type {import("ol/Collection.js").default}
   */
  this.features = new olCollection();

  /**
   * @type {string}
   */
  this.pointGeomType = ngeoGeometryType.POINT;

  /**
   * @type {string}
   */
  this.lineStringGeomType = ngeoGeometryType.LINE_STRING;

  /**
   * @type {string}
   */
  this.polygonGeomType = ngeoGeometryType.POLYGON;

  const vector = new olLayerVector({
    source: new olSourceVector({
      wrapX: false,
      features: this.features
    })
  });

  /**
   * @type {import("ol/Map.js").default}
   */
github camptocamp / ngeo / src / measure / length.js View on Github external
const measureLength = new ngeoInteractionMeasureLength(
        $filter('ngeoUnitPrefix'), gettextCatalog, options
      );

      if (drawFeatureCtrl.uid) {
        measureLength.set(
          'ngeo-interaction-draw-uid',
          `${drawFeatureCtrl.uid}-length`
        );
      }

      drawFeatureCtrl.registerInteraction(measureLength);
      drawFeatureCtrl.measureLength = measureLength;

      listen(measureLength, 'measureend',
        drawFeatureCtrl.handleDrawEnd.bind(drawFeatureCtrl, ngeoGeometryType.LINE_STRING),
        drawFeatureCtrl
      );
      listen(measureLength, 'change:active', drawFeatureCtrl.handleActiveChange, drawFeatureCtrl);
    }
  };