【发布时间】:2019-10-09 19:30:47
【问题描述】:
我有一个问题,我有一个 sqlite.geojson 文件,我想从中获取一些信息,例如,我怎样才能获得“30”的“ORIENTATION”值?
这里是 sqlite.geojson
{
"type": "FeatureCollection",
"name": "TARGET",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "ID": 1, "COORDINATEX": "23", "COORDINATEY": "46", "ORIENTATION": "30" }, "geometry": null },
{ "type": "Feature", "properties": { "ID": 2, "COORDINATEX": "25", "COORDINATEY": "46", "ORIENTATION": "90" }, "geometry": null }
]
}
还有Js代码
var vectorGeojson = new VectorSource({
format: new GeoJSON(),
url: 'data/sqlite.geojson'
});
var vectorGeojsonLayer = new VectorLayer({
source: vectorGeojson,
style: styleFunction
});
var map = new Map({
controls: defaultControls().extend([mousePositionControl]),
layers: [rasterLayer, vectorLayer, vectorGeojsonLayer],
target: 'map',
view: new View({
center:fromLonLat([-46.68, -23.59]),
zoom: 2
})
});
【问题讨论】:
-
如果要素已加载到图层源中,请使用
feature.get("ORIENTATION")
标签: javascript openlayers geojson