MapStore2
MapStore2 copied to clipboard
When using the JS API, GeoJSON layers only show the last 2 geometries
Description
This is caused by a bug in the leaflet implementation of the Feature component. The problem is here: https://github.com/geosolutions-it/MapStore2/blob/master/web/client/components/map/leaflet/Feature.jsx#L113
Using a lodash deepClone instead of the JS spread operator solves the issue (the style object is not a simple value object, but a class in a complex hierarchy, so properties are in nested prototypes and are not copied by the spread operator).
How to reproduce
Create a JS API app and add the following trigger:
MapStore2.triggerAction({
type: 'ADD_LAYER',
layer: {
"type" : "vector",
"name": "TestJSON",
"visibility": true,
"features" : [
{
"type": "Feature",
"id":1,
"geometry": {
"type": "Point",
"coordinates": [11,44]
},
"properties": {}
},
{
"type": "Feature",
"id":2,
"geometry": {
"type": "Point",
"coordinates": [12,44]
},
"properties": {}
},
{
"type": "Feature",
"id":3,
"geometry": {
"type": "Point",
"coordinates": [13,44]
},
"properties": {}
},
{
"type": "Feature",
"id":4,
"geometry": {
"type": "Point",
"coordinates": [14,44]
},
"properties": {}
}
]
}
});
Expected Result
4 points are shown Current Result
only 2 points are shown
- [x] Not browser related
Browser info
(use this site: https://www.whatsmybrowser.org/ for non expert users)| Browser Affected | Version |
|---|---|
| Internet Explorer | |
| Edge | |
| Chrome | |
| Firefox | |
| Safari |