PilotGaea 2D O'view
    正在準備搜尋索引...

    類別 Feature

    A vector object for geographic features with a geometry and other attribute properties, similar to the features in vector file formats like GeoJSON.

    Features can be styled individually with setStyle; otherwise they use the style of their vector layer.

    Note that attribute properties are set as ol.Object properties on the feature object, so they are observable, and have get/set accessors.

    Typically, a feature has a single geometry property. You can set the geometry using the setGeometry method and get it with getGeometry. It is possible to store more than one geometry on a feature using attribute properties. By default, the geometry used for rendering is identified by the property name geometry. If you want to use another geometry property for rendering, use the setGeometryName method to change the attribute property associated with the geometry for the feature. For example:

    var feature = new ol.Feature({
    geometry: new ol.geom.Polygon(polyCoords),
    labelPoint: new ol.geom.Point(labelCoords),
    name: 'My Polygon'
    });

    // get the polygon geometry
    var poly = feature.getGeometry();

    // Render the feature as a point using the coordinates from labelPoint
    feature.setGeometryName('labelPoint');

    // get the point geometry
    var point = feature.getGeometry();

    You may pass a Geometry object directly, or an object literal containing properties. If you pass an object literal, you may include a Geometry associated with a geometry key.

    stable

    層級 (查看層級一覽)

    索引

    方法

    • Removes an event listener using the key returned by on() or once().

      參數

      • key: Object | Object[]

        The key returned by on() or once() (or an array of keys).

      回傳 void

      stable

    • Clone this feature. If the original feature has a geometry it is also cloned. The feature id is not set in the clone.

      回傳 ol.Feature

      The clone.

      stable

    • Get the feature's default geometry. A feature may have any number of named geometries. The "default" geometry (the one that is rendered by default) is set when calling ol.Feature#setGeometry.

      回傳 ol.geom.Geometry

      The default geometry for the feature.

      stable

    • Get the feature identifier. This is a stable identifier for the feature and is either set when reading data from a remote source or set explicitly by calling ol.Feature#setId.

      回傳 string | number

      Id.

      stable

    • Get the name of the feature's default geometry. By default, the default geometry is named geometry.

      回傳 string

      Get the property name associated with the default geometry for this feature.

      stable

    • Get the feature's style function.

      回傳 FeatureStyleFunction

      Return a function representing the current style of this feature.

      stable

    • Set the default geometry for the feature. This will update the property with the name returned by ol.Feature#getGeometryName.

      參數

      回傳 void

      stable

    • Set the style for the feature. This can be a single style object, an array of styles, or a function that takes a resolution and returns an array of styles. If it is null the feature has no style (a null style).

      參數

      回傳 void

      stable

    • Set the feature id. The feature id is considered stable and may be used when requesting features or comparing identifiers returned from a remote source. The feature id can be used with the ol.source.Vector#getFeatureById method.

      參數

      • id: string | number

        The feature id.

      回傳 void

      stable

    • Set the property name to be used when getting the feature's default geometry. When calling ol.Feature#getGeometry, the value of the property with this name will be returned.

      參數

      • name: string

        The property name of the default geometry.

      回傳 void

      stable

    • Gets a value.

      參數

      • key: string

        Key name.

      回傳 any

      Value.

      stable

    • Get a list of object property names.

      回傳 string[]

      List of property names.

      stable

    • Get an object of all property names and values.

      回傳 { [k: string]: any }

      Object.

      stable

    • Sets a value.

      參數

      • key: string

        Key name.

      • value: any

        Value.

      • 可選opt_silent: boolean

        Update without triggering an event.

      回傳 void

      stable

    • Sets a collection of key-value pairs. Note that this changes any existing properties and adds new ones (it does not remove any existing properties).

      參數

      • values: { [k: string]: any }

        Values.

      • 可選opt_silent: boolean

        Update without triggering an event.

      回傳 void

      stable

    • Unsets a property.

      參數

      • key: string

        Key name.

      • 可選opt_silent: boolean

        Unset without triggering an event.

      回傳 void

      stable

    • Increases the revision counter and dispatches a 'change' event.

      回傳 void

    • 函數

      Dispatches an event and calls all listeners listening for events of this type. The event parameter can either be a string or an Object with a type property.

      參數

      回傳 void

    • Get the version number for this object. Each time the object is modified, its version number will be incremented.

      回傳 number

      Revision.

    • Listen for a certain type of event.

      參數

      • type: string | string[]

        The event type or array of event types.

      • listener: Function

        The listener function.

      • 可選opt_this: Object

        The object to use as this in listener.

      回傳 Object | Object[]

      Unique key for the listener. If called with an array of event types as the first argument, the return will be an array of keys.

      stable

    • Listen once for a certain type of event.

      參數

      • type: string | string[]

        The event type or array of event types.

      • listener: Function

        The listener function.

      • 可選opt_this: Object

        The object to use as this in listener.

      回傳 Object | Object[]

      Unique key for the listener. If called with an array of event types as the first argument, the return will be an array of keys.

      stable

    • Unlisten for a certain type of event.

      參數

      • type: string | string[]

        The event type or array of event types.

      • listener: Function

        The listener function.

      • 可選opt_this: Object

        The object which was used as this by the listener.

      回傳 void

      stable

    • 函數

      Removes an event listener using the key returned by on() or once(). Note that using the ol.Observable.unByKey static function is to be preferred.

      參數

      • key: Object | Object[]

        The key returned by on() or once() (or an array of keys).

      回傳 void

      stable

    構造函數

    • 參數

      • 可選opt_geometryOrProperties: ol.geom.Geometry | { [k: string]: any }

        You may pass a Geometry object directly, or an object literal containing properties. If you pass an object literal, you may include a Geometry associated with a geometry key.

      回傳 ol.Feature

      A vector object for geographic features with a geometry and other attribute properties, similar to the features in vector file formats like GeoJSON.

      Features can be styled individually with setStyle; otherwise they use the style of their vector layer.

      Note that attribute properties are set as ol.Object properties on the feature object, so they are observable, and have get/set accessors.

      Typically, a feature has a single geometry property. You can set the geometry using the setGeometry method and get it with getGeometry. It is possible to store more than one geometry on a feature using attribute properties. By default, the geometry used for rendering is identified by the property name geometry. If you want to use another geometry property for rendering, use the setGeometryName method to change the attribute property associated with the geometry for the feature. For example:

      var feature = new ol.Feature({
      geometry: new ol.geom.Polygon(polyCoords),
      labelPoint: new ol.geom.Point(labelCoords),
      name: 'My Polygon'
      });

      // get the polygon geometry
      var poly = feature.getGeometry();

      // Render the feature as a point using the coordinates from labelPoint
      feature.setGeometryName('labelPoint');

      // get the point geometry
      var point = feature.getGeometry();

      stable