openlayer ol.feature

import Feature from 'ol/feature';

地理特征与几何和其他属性的矢量对象,类似于特征矢量文件格式如GeoJSON。

功能可以单独的设计setStyle; 否则,他们利用他们的矢量图层样式。

注意,属性设置为ol.Object 属性的特征对象,所以他们是可见的,并已获得/设置访问器。

通常,特性具有单个几何属性。你可以设置使用setGeometrygetGeometry得到它。

使用属性属性在一个特性上存储多个几何体是可能的。默认情况下,渲染所使用的几何体是由属性名称几何标识geometry的。如果你想使用另一个几何特征的渲染,使用setGeometryName 方法改变为特征的几何关联的属性。例如:

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();

new ol.Feature(opt_geometryOrProperties)

Name Type Description
geometryOrProperties ol.geom.Geometry|Object.<string, *>=

您可以直接传递几何对象,或者包含属性的对象文字。如果传递对象文字,则可以包含与几何键相关联的几何图形。

Fires:

转载自:https://blog.csdn.net/qq_17634969/article/details/79192915

You may also like...