tangrams / tangram

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

Dot density maps and collision funk #578

Open nvkelso opened 7 years ago

nvkelso commented 7 years ago

The collision logic described here is not working for me:

Says:

- Points collide: false, text collide: true: all points will render, text will render if it fits. - Points collide: true, text collide: false: points will render if they fit, in which case their attached text will also render, even if it overlaps something else.

points: { collide: false, text: { visible: false } }

All ~600 of my points, yeah!

See: https://mapzen.com/tangram/view/?api=506/875#4.622/40.370/-111.484 Archived as: https://gist.github.com/nvkelso/71168b641677ff9193e8b92f8c9de842

screen shot 2017-08-12 at 11 37 00

Now let's try to add some labels:

points: { collide: false, text: { collide: true } }

I expect to see many more dots in this view:

screen shot 2017-08-12 at 11 30 57

points: { collide: false, text: { collide: false } }

This does properly show all dots, but now labels cover all the dots and each other 😿

screen shot 2017-08-12 at 11 29 44

I really want an option for all the dots to show up, but be under (e.g. not collide) the dots that get labels. So I create a new style using inlay.

    dot_distribution:
        base: points
        blend: inlay

When I add a new source under the first layer with the collide settings using the inlay style I finally achieve the design I'm looking for:

screen shot 2017-08-12 at 11 31 40

Recommendation:

It would be nice to specify something like order for the points and if points: { collide: false, text: { collide: true } } is set than the points that don't get text should be under the points that do, and the priority should also affect the order (worse priority points sometimes cover better priority points, even if their text collides properly using the priority number – see the overlapping San Francisco and San Francisco State University labels).

nvkelso commented 7 years ago

Another related funk is I suspect non-tiled GeoJSON is being tiled into 256px tiles when larger 512px blocks would create better labels.

nvkelso commented 7 years ago

/cc @burritojustice

bcamper commented 7 years ago

While there is probably more than this going on in the background, for your second example, have you tried optional: true on the nested text? Remember it defaults to false (at your request ;) so that points will only appear if they're text fits too.

bcamper commented 7 years ago

Agree that switching internal tiling of non-tiled sources to 512px is a good idea. Need to look into it.

nvkelso commented 7 years ago

While there is probably more than this going on in the background, for your second example, have you tried optional: true on the nested text? Remember it defaults to false (at your request ;) so that points will only appear if they're text fits too.

Aha! I do remember now. But the documentation doesn't say anything about that and needs a fix.

https://mapzen.com/documentation/tangram/draw/#text-behavior

However the results with text: { optional: true } are still less than desired, with seemingly random order instead of listening to the priority I set (code snippet below) – and the features that do include labels need to be on top of the features without text generally:

screen shot 2017-08-14 at 09 31 35
                priority:  |
                    function() { 
                        var order = 1000 + feature.rank * 100;
                        if( feature.placetype === 'campus') {
                            order += 50;
                        }
                        return order;
                    }
nvkelso commented 7 years ago

Added PR for the documentation change here: https://github.com/tangrams/tangram-docs/pull/223.

bcamper commented 7 years ago

@nvkelso change here to tile non-tiled sources to 512px: https://github.com/tangrams/tangram/commit/c7506ba4ee3b16bb6146222e3a82b97197cc8ade

burritojustice commented 7 years ago

re non-tiled and 256px vs 512px, I suspect it's why I'm not seeing all of the TIGER block labels in this map at z15, when there seems to be plenty of room

image

https://mapzen.com/tangram/play/?scene=https%3A%2F%2Fmapzen.com%2Fapi%2Fscenes%2F22%2F862%2Fresources%2Fblank.yaml#14.4209/37.7774/-122.4111