datamade / clearstreets-web

Website that tracks where Chicago plows have been during a snowstorm.
http://clearstreets.org
MIT License
7 stars 6 forks source link

Disappearing line segments at higher zooms. #7

Closed fgregg closed 10 years ago

fgregg commented 10 years ago

Apparently this is a known issue that CartoDB is working on and may have a fix for soon. In the meantime, this could be a workaround.

Using the visualization you created in the CartoDB dashboard, add a second layer. Create the second layer from the same data. Move this layer underneath the first layer. Don't add any infowindows or anything to this layer. Set the style the same as the other layer. Set the SQL to this,

SELECT ST_Collect(the_geom_webmercator) the_geom_webmercator FROM tablename

What this will do is turn the entire dataset into a single linestring. It will trick our system, which is where the current bug comes from, there is an artificial limit on features in tiles.

Another enhancement is once you have the styled single layer underneath, you could make the upper layer transparent, only using it for click events. But no worries if you don't go that far.

derekeder commented 10 years ago

Created the 'hack layer': http://cdb.io/1gDVSQq and added it to the site.

andrewxhill commented 10 years ago

It seems like you don't have interactivity anymore. You need to have the first layer you created still (even though it wont show all the data, it shouldn't be a problem since they are styled the exact same) because it will contain the interactivity for each individual line segment

andrewxhill commented 10 years ago

yep, you only have one layer in the visualization here,

http://clearstreets.cartodb.com/api/v2/viz/589c99a4-673a-11e3-bc87-37a820bb3867/viz.json

you want to have one layer that is the SELECT st_collect(the_geom_webmercator)... the one on top of that is the normal SELECT * ...

derekeder commented 10 years ago

@andrewxhill ah but I'm layering them together on http://clearstreets.org/ (see https://github.com/open-city/clearstreets-web/commit/f231582ad94947b4d6986c38db6ee52ce44e0fee)

Sounds like it might be easiest to do the layering in CartoDB so I only link to one viz layer in my javascript.

andrewxhill commented 10 years ago

yeah, totally. it will make the server combine the layers into a single tileset for you.