有人可以给我一个例子,如何从 harp.gl 中的 geojson LineString 中绘制一条线? 教程和文档缺少它。
目前我正在 index.js 中尝试使用此方法:
fetch('my_data.geojson')
.then(data => data.json())
.then(data => {
const geoJsonDataProvider = new harp.GeoJsonDataProvider("my_data", data);
const geoJsonDataSource = new harp.OmvDataSource({
dataProvider: geoJsonDataProvider,
name: "my_data"
});
map.addDataSource(geoJsonDataSource).then(() => {
const styles = [{
when: "$geometryType == 'line'",
renderOrder: 10000,
attr: {
color: 0x000000fe,
size: 30
}
}]
geoJsonDataSource.setStyleSet(styles);
map.update();
});
});
在 geojson.io 生成的 my_data.geojson
最佳答案
我刚刚错过了该样式的一些属性。 使用这种风格,效果很好:
const styles = [{
"when": "$geometryType ^= 'line'",
"renderOrder": 1000,
"technique": "solid-line",
"attr": {
"color": "blue",
"opacity": 1,
"metricUnit": "Pixel",
"lineWidth": 4
}
}];
关于javascript - 使用 harp.gl 从 geojson 画一条线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58774503/