martin
martin copied to clipboard
Set id to feature
Is there a way to set id
to feature (last param of ST_AsMVT
function)?
id
from table is not passed to feature id.
Or int value:
Hi! You can do it in your frontend as well (Mapbox GL JS). Call your id (int or string) on the function source and then:
map.addSource('counties', {
"type": "vector",
"url" || "tiles": "your url / tiles",
"promoteId": "your id"
});
@AdriSolid For now I do it with custom function and ST_AsMVT
(https://postgis.net/docs/ST_AsMVT.html) takes last param as feature_id_name, but your advice is very helpful too. Thanks!
Will leave doc link here for the community: https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#vector-promoteId
great idea @AdriSolid but that is a very Mapbox GL specific feature. I do, think this feature is very valuable to have in API itself that way it's available agnostic of which client is being used to render the tiles.
This is partially already implemented, and will be cleaned up and fixed in #380