GeoJSON example does not work with OL v8.2.0 and TypeScript #15463
Answered
by
mprins
anttikekki
asked this question in
Q&A
-
OpenLayers 8.2.0 GeoJSON example does not work with TypeScript. What is the current correct way to use GeoJSON with VectorSource + VectorLayer? const vectorSource = new VectorSource({
features: new GeoJSON().readFeatures(geojsonObject),
});
// vectorSource is VectorSource<FeatureLike>
vectorSource.addFeature(new Feature(new Circle([5e6, 7e6], 1e6)));
const vectorLayer = new VectorLayer({
source: vectorSource, // compile error!
style: styleFunction,
});
// vectorLayer is VectorLayer<VectorSource<Feature<Geometry>>>
If I try to specify source type for the const vectorSource = new VectorSource({
features: new GeoJSON().readFeatures(geojsonObject),
});
// vectorSource is VectorSource<FeatureLike>
vectorSource.addFeature(new Feature(new Circle([5e6, 7e6], 1e6)));
const vectorLayer = new VectorLayer<VectorSource<FeatureLike>>({ // compile error!
source: vectorSource,
style: styleFunction,
}); Error:
|
Beta Was this translation helpful? Give feedback.
Answered by
mprins
Jan 5, 2024
Replies: 1 comment
-
duplicates #15356 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
anttikekki
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
duplicates #15356