tangrams / tangram

WebGL map rendering engine for creative cartography
https://tangram.city
MIT License
2.22k stars 290 forks source link

Support float values in priority for label collision #692

Open nvkelso opened 5 years ago

nvkelso commented 5 years ago

Following up from https://github.com/tilezen/vector-datasource/issues/988, it sounds like Tangram JS does support float values on the priority property (but Tangram ES does not currently). Let's verify that and if so update the documentation. Else add support and document.

This comment is the tl;dr:

Specifically, this should allow a function like (which returns a float):

priority = feature.properties.min_zoom + (1 - 1 / feature.properties.collision_rank) * 0.1

Alternatively we've also talked about multi-key priority which could give more performance than a JS function. For example:

priority: [min_zoom, collision_rank]

Though in some other cases (like name) we treat lists as fallbacks not tie breakers.

nvkelso commented 5 years ago

@bcamper I nominate this for v0.17 milestone :)

bcamper commented 5 years ago

Confirmed fractional priorities work in Tangram JS already. So no code change :) Documentation should be updated, I'll leave this open for that -- but perhaps wait until it is supported in ES too, so we don't have to update twice?

So what we will want in the scene file is:

priority: function(){ return feature.min_zoom + (1 - 1 / feature.collision_rank) * 0.1; }