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:
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章