{"action":"closed","issue":{"url":"https://api.github.com/repos/CartoDB/cartodb.js/issues/1020","repository_url":"https://api.github.com/repos/CartoDB/cartodb.js","labels_url":"https://api.github.com/repos/CartoDB/cartodb.js/issues/1020/labels{/name}","comments_url":"https://api.github.com/repos/CartoDB/cartodb.js/issues/1020/comments","events_url":"https://api.github.com/repos/CartoDB/cartodb.js/issues/1020/events","html_url":"https://github.com/CartoDB/cartodb.js/issues/1020","id":129524829,"number":1020,"title":"Associate filters directly to map.layers","user":{"login":"alonsogarciapablo","id":390398,"avatar_url":"https://avatars.githubusercontent.com/u/390398?v=3","gravatar_id":"","url":"https://api.github.com/users/alonsogarciapablo","html_url":"https://github.com/alonsogarciapablo","followers_url":"https://api.github.com/users/alonsogarciapablo/followers","following_url":"https://api.github.com/users/alonsogarciapablo/following{/other_user}","gists_url":"https://api.github.com/users/alonsogarciapablo/gists{/gist_id}","starred_url":"https://api.github.com/users/alonsogarciapablo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alonsogarciapablo/subscriptions","organizations_url":"https://api.github.com/users/alonsogarciapablo/orgs","repos_url":"https://api.github.com/users/alonsogarciapablo/repos","events_url":"https://api.github.com/users/alonsogarciapablo/events{/privacy}","received_events_url":"https://api.github.com/users/alonsogarciapablo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/CartoDB/cartodb.js/labels/v4","name":"v4","color":"bfdadc"}],"state":"closed","locked":false,"assignee":{"login":"acanimal","id":732033,"avatar_url":"https://avatars.githubusercontent.com/u/732033?v=3","gravatar_id":"","url":"https://api.github.com/users/acanimal","html_url":"https://github.com/acanimal","followers_url":"https://api.github.com/users/acanimal/followers","following_url":"https://api.github.com/users/acanimal/following{/other_user}","gists_url":"https://api.github.com/users/acanimal/gists{/gist_id}","starred_url":"https://api.github.com/users/acanimal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acanimal/subscriptions","organizations_url":"https://api.github.com/users/acanimal/orgs","repos_url":"https://api.github.com/users/acanimal/repos","events_url":"https://api.github.com/users/acanimal/events{/privacy}","received_events_url":"https://api.github.com/users/acanimal/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2016-01-28T17:50:11Z","updated_at":"2016-02-23T14:50:53Z","closed_at":"2016-02-23T14:50:53Z","body":"Right now filters \"belong\" to dataviews, which are related to layers. So we're doing things like:\r\n\r\n```\r\n   var filtersFromVisibleLayers = [];\r\n    if (dataviews) {\r\n      filtersFromVisibleLayers = dataviews.chain()\r\n        .filter(function (dataview) { return dataview.layer.isVisible(); })\r\n        .map(function (dataview) { return dataview.filter; })\r\n        .compact() // not all dataviews have filters\r\n        .value();\r\n    }\r\n```\r\n\r\nWe're also having to [set a `layerIndex` on filters](https://github.com/CartoDB/cartodb.js/blob/v4/src/dataviews/dataviews-factory.js#L56) so they can be grouped together when [we serialize them to send them to Windshaft](https://github.com/CartoDB/cartodb.js/blob/v4/src/windshaft/filters/collection.js#L12-L21).\r\n\r\nAll this would be easier if filters were associated to layers directly. Plus, it conceptually makes more sense IMO.\r\n\r\ncc: @viddo \r\n"}}