How to use the ngeo/GeometryType.js.POLYGON 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 / editing / editFeatureComponent.js View on Github external
// show contextual menu when clicking on certain types of features
    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 / contribs / gmf / src / drawing / drawFeatureComponent.js View on Github external
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',
        label: vertexInfo ? gettextCatalog.getString('Delete vertex') :
github camptocamp / ngeo / src / measure / area.js View on Github external
options.precision = $injector.get('ngeoMeasurePrecision');
      }
      const measureArea = new ngeoInteractionMeasureArea($filter('ngeoUnitPrefix'), gettextCatalog, options);

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

      drawFeatureCtrl.registerInteraction(measureArea);
      drawFeatureCtrl.measureArea = measureArea;

      listen(measureArea, 'measureend', drawFeatureCtrl.handleDrawEnd.bind(
        drawFeatureCtrl, ngeoGeometryType.POLYGON
      ), drawFeatureCtrl);
      listen(measureArea, 'change:active', drawFeatureCtrl.handleActiveChange, drawFeatureCtrl);
    }
  };
github camptocamp / ngeo / examples / createfeature.js View on Github external
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}
   */
  this.map = new olMap({
    layers: [
      new olLayerTile({
        source: new olSourceOSM()
      }),