-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
query*Features should preserve non-integer feature IDs #2716
Comments
Upstream PR which this depends on: mapbox/geojson-vt#60. |
This was fixed on the geojson-vt side, but now ids don't survive the transfer through |
@mourner I'm excited to (finally!) make geobuf part of GL JS!! Have you considered transferring the feature ids through a specially named property, like |
@lucaswoj we could do this, but this feels kinda hacky and fragile to me (e.g. what if the data has both |
Then our |
@anandthakker thanks! I was referring to the vector-tile-spec limitation of having ids as uints which John pointed out in the PR, so the original issue would still be present as string ids are not encoded. |
Ahhh, this problem goes deeper than I realized -- I read too quickly 😄. And anyway, the geobuf thing sounds like a much better solution, ultimately! |
Note that per #4494 (comment), polygon layers manifest this problem more severely, crashing (due to pbf parsing problems) rather than simply stripping the id. This may indicate an upstream bug in |
The crashing was introduced by a change in v0.33.0. Prior to that polygon layers would simply strip the id but continue to work. |
@anandthakker just thinking about this a little more. It's your choice, but I'm wondering if this makes sense to be the same issue? |
good point @gmaclennan - I think you're right. I'll reopen 4944 to track the crash. Thanks for following up / setting me straight! |
Hi there! It's looking like the lack of string ID support is going to be a blocker for me shortly, and I'm definitely willing to work on a PR to get this fixed. I just want to double check: is the plan here still to swap in geobuf for the current encoding scheme when communicating between the main js thread and the worker? |
So, today's the day I need to start working on this – I'm going to try swapping in geobuf for communication to the web worker, and I'll submit a PR if I get it working, but I would definitely appreciate an early nudge in a better direction or confirmation that this is still the best strategy to fixing this. |
Hey @mike-marcacci -- sorry for the delay! Confirming that using |
@hyperknot there are no performance benefits, but the |
Why mapbox didn't support string ids? I read comments on this issue but don't understand why id forced to be number? |
I am confused as well. For example it makes things unnecessarily difficult if you are working with geojson WFS data hosted from a geoserver where the id comes as a string in the format |
For me it is also important, because we use ubid for buildings which is a string. To use states we need to use this as id. |
Is there any update on the type for feature.id ? I'm using uuid (string) as well so allowing string would keep things consistent. |
Bump Same, our project uses String type |
Same here, I'm using mapbox-gl-draw that returns IDs on feature but then removed when using setData |
@asheemmamoowala Thank you! Using |
@asheemmamoowala thanks for replying! I'm trying to use
|
@karen1au does this work? this.map.addSource(sector.id, {
type: 'geojson',
promoteId: 'id',
data: {
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: sector.boundaries.coordinates
},
properties: {
id: sector.id
}
}
}); |
@mingjunlu that works, but I think @karen1au is maybe wondering (and me too), if there's a way to use the feature.id property rather than the feature.properties.id |
Hi, @chriszrc Do you find the way to use the feature.Id as promoted? I do not have Id in properties and I do not have control over the data. Also, I want to avoid adding the id in properties because of performance. |
@hmendezm unfortunately no. I moved the id to the properties, and then it worked. I never was able to have it work from feature.id |
ohk. Thanks @chriszrc. in the case, I have to do the same. sucks |
Refactor to remove react-mapbox-gl dep, since our use case is simple (just lots of layer declarations) and the dependency adds complexity and larger bundles. String geojson feature IDs don't get copied into the vector tiles, thus can't be used for "feature state": mapbox/mapbox-gl-js#2716 Work around just uses osm object id via "promoteId". It's possible but unlikely that two objects of different types could share the same int id in a single diff. I think the behavior in this case is just that both elements with the same id would receive the same hover state. The duplicate is likely offscreen.
Even tho promoteId works, this is pretty clunky to use. So allowing for strings in ids directly would be much nicer! |
Bumping. Any update on that? When string id will be preserved without any additional config like |
Bumping. I run into this on an annual basis, and each time I can't believe this incompatibility with the GeoJSON spec hasn't been fixed yet! I'd have to say it's my major pain point using Mapbox. |
How is this still a thing.... |
Bumping this. Running into major headaches not being able to use strings as feature ids. |
Here's a jsbin demonstrating the issue:
https://jsbin.com/bafewapela/edit?html,console,output
The GeoJSON spec states that features may have a top-level id property:
However, when I have a source with such a feature:
add it to the map and then get features back via
queryRenderedFeatures
, theid
is gone. Theproperties
andgeometry
properties are there, butid
is not. It would be really helpful if this special property were preserved.The workaround is to duplicate IDs into
properties.id
before adding features to the map, but this creates extra work and contradicts the GeoJSON spec.mapbox-gl-js version: 0.19.1
The text was updated successfully, but these errors were encountered: