I have a Mapbox GL with one layer and several markers at this level, I'm trying to update a specific marker, so I use setData to update only one marker, but setData will reset the whole layer to add only what I'm trying to update as a single marker over the entire layer, thereby removing all old markers.
By adding multiple markers in the GEOJson format as an array of GEOJson objects, as shown below, I get an error message:
Uncaught Error: Input data is not a valid GeoJSON object.
the code:
map.getSource('cafespots').setData([{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [31.331849098205566, 30.095422632059062]
},
"properties": {
"marker-symbol": "cafe"
}
},{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [31.39, 30.10]
},
"properties": {
"marker-symbol": "cafe"
}
}]);
I will feel it this way if someone can help by telling me what I'm doing wrong / missing here, thanks
source
share