Replies: 1 comment
-
|
I generally agree that there should either be an error message, console warn or that the invalid geometries will be ignored. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
tl;dr : You can load invalid geojson features into a geojson source, but updating them with .updateData() to be valid won't make them render on the map, even though the source's data reflects the update.
I'm working with an array of objects that have assignable locations (points). So as not be flipping back and forth between representations of the same object, I just formatted my objects to look like geojson, and if they didn't have a location set yet, I made the geometry field set to null. I took this array of objects and fed it directly into a geojson source, and as [I] expected, my layer only mapped features that had valid geometries.
However, I tried to then update the source data using .updateData() (i.e. I assigned locations to objects) and found that I could not get my newly assigned locations to render. This is the bevahior whether I use the "add" or "update" slot in the diff. If I wait for the update to complete, and then check the data in the source using .getData(), it returns an array of features with correctly updated data, but they just aren't rendered on the map. I started to listen to 'data' events, and saw that the data is correctly updated there as well. A call to map.redraw() also doesn't render my new feature geometry. As a bit of debugging, I just fed the data from getData() back into .setData() and my new features were correctly rendered (i.e updateData(updates) => getData() => setData() correctly renders what updateData(updates) alone does not).
I know the premise of this is all based on the fact that I am starting with invalid geojson in the first place, but I thought I might post here to see if this is the expected behavior, because I can do all of the above and have no error messages along the way. I also know I can just use .setData() to accomplish my update (and I think of many other solutions as well), but this is really just a post to see if this is within expected behavior for the updateData() method. I personally think it is a bit odd to be able to force a source, using its own methods, into a state where there are valid geojson features in its internal state that are not rendered on the map.
Beta Was this translation helpful? Give feedback.
All reactions