Skip to content
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

Use id property as feature id if not exist. #69

Closed
Asteb612 opened this issue Jan 30, 2020 · 2 comments
Closed

Use id property as feature id if not exist. #69

Asteb612 opened this issue Jan 30, 2020 · 2 comments

Comments

@Asteb612
Copy link

Asteb612 commented Jan 30, 2020

The goal is to use MVT tile generated by ST_AsMVT function on postgis 2.4 and 2.5.
Because feature id is not provided mapbox-gl throw this error :
Error: The feature id parameter must be provided.

Today the solution i found is to make this modification directly on sources and rebuild mapboxgl :

diff --git a/lib/vectortilefeature.js b/lib/vectortilefeature.js
index b9880a1..474fdfd 100644
--- a/lib/vectortilefeature.js
+++ b/lib/vectortilefeature.js
@@ -17,6 +17,10 @@ function VectorTileFeature(pbf, end, extent, keys, values) {
     this._values = values;
 
     pbf.readFields(readFeature, this, end);
+
+    if ('id' in this.properties && !this.id) {
+       this.id = this.properties.id;
+    }
 }

I think this modification can be useful to some people that can't update postgis to 3.0 version.

@Asteb612
Copy link
Author

Asteb612 commented Jan 30, 2020

I have created a issue because i don't have the access right to create a pull request.

@mourner
Copy link
Member

mourner commented Feb 7, 2020

We can't really do that because Vector Tile Spec v2 does not support string ids, while property values can be strings. However, Mapbox GL JS v1.7.0 has a feature that makes this unnecessary — promoteId, see mapbox/mapbox-gl-js#8987

@mourner mourner closed this as completed Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants