{"action":"created","issue":{"url":"https://api.github.com/repos/openlayers/ol3/issues/4671","labels_url":"https://api.github.com/repos/openlayers/ol3/issues/4671/labels{/name}","comments_url":"https://api.github.com/repos/openlayers/ol3/issues/4671/comments","events_url":"https://api.github.com/repos/openlayers/ol3/issues/4671/events","html_url":"https://github.com/openlayers/ol3/issues/4671","id":126415983,"number":4671,"title":"setSource() on a layer causes it to be rendered blank after modifying the map's layer collection","user":{"login":"albertov","id":865291,"avatar_url":"https://avatars.githubusercontent.com/u/865291?v=3","gravatar_id":"","url":"https://api.github.com/users/albertov","html_url":"https://github.com/albertov","followers_url":"https://api.github.com/users/albertov/followers","following_url":"https://api.github.com/users/albertov/following{/other_user}","gists_url":"https://api.github.com/users/albertov/gists{/gist_id}","starred_url":"https://api.github.com/users/albertov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertov/subscriptions","organizations_url":"https://api.github.com/users/albertov/orgs","repos_url":"https://api.github.com/users/albertov/repos","events_url":"https://api.github.com/users/albertov/events{/privacy}","received_events_url":"https://api.github.com/users/albertov/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-13T13:16:59Z","updated_at":"2016-01-14T09:48:10Z","closed_at":"2016-01-14T09:48:09Z","body":"Changing a layer's source after the map's layer collection has been modified by removing other layers causes the layer to be rendered blank.\r\n\r\nChanging the source works as expected before the other layers have been removed.\r\n\r\nTested on Chrome 45.0.2454.85 (64-bit) and Safari 9.0.2 (11601.3.9) (both on OSX)\r\n\r\nThe following example demonstrates it:\r\n\r\n```html\r\n<!DOCTYPE html>\r\n<html>\r\n  <head>\r\n    <title>ol.source.MapQuest.setSource bug</title>\r\n    <link rel=\"stylesheet\" href=\"http://openlayers.org/en/v3.12.1/css/ol.css\" type=\"text/css\">\r\n    <script src=\"http://openlayers.org/en/v3.12.1/build/ol.js\"></script>\r\n  </head>\r\n  <body>\r\n    <div id=\"map\" class=\"map\"></div>\r\n    <script>\r\n      var map = new ol.Map({\r\n        layers: [\r\n            new ol.layer.Tile({\r\n              source:new ol.source.TileWMS({\r\n                url: \"http://demo.boundlessgeo.com/geoserver/wms\",\r\n                params: {\"LAYERS\":\"topp:states\"}\r\n              })\r\n            })\r\n          , new ol.layer.Group({\r\n              layers:new ol.Collection([\r\n                    new ol.layer.Tile({\r\n                      source:new ol.source.TileWMS({\r\n                        url: \"http://demo.boundlessgeo.com/geoserver/ne/wms\",\r\n                        params: {\"LAYERS\":\"ne:ne_10m_admin_0_countries\",\r\n                          \"TILED\":\"true\"}\r\n                      })\r\n                    })\r\n                  , new ol.layer.Tile({source:new ol.source.OSM()})\r\n                  ])\r\n                })\r\n          , new ol.layer.Tile({source:new ol.source.MapQuest({layer:'sat'})})\r\n        ]\r\n      , target: 'map'\r\n      , view: new ol.View({\r\n          center: [0, 0],\r\n          zoom: 1\r\n        })\r\n      });\r\n      var layers = map.getLayerGroup().getLayers()\r\n        , mapQuestLayer = layers.item(2);\r\n\r\n      function toggleSource () {\r\n        var layer = mapQuestLayer.getSource().getLayer()==\"sat\"?\"osm\":\"sat\";\r\n        var newSource = new ol.source.MapQuest({layer:layer});\r\n        mapQuestLayer.setSource(newSource);\r\n      }\r\n\r\n      function removeTwoLayers() {\r\n        layers.remove(layers.item(0));\r\n        layers.remove(layers.item(0));\r\n      }\r\n\r\n      function breakIt() {\r\n        removeTwoLayers();\r\n        toggleSource();\r\n      }\r\n    </script>\r\n    <p>To reproduce bug either press \"Break it\" or \"Remove two layers\" and then\r\n    \"Toggle source\"</p>\r\n    <p>The map should turn blank event though the MapQuest layer is still there\r\n    and sending \"change\" events (open the Attribution panel and toggle sources\r\n    to confirm it)</p>\r\n    <button onclick=\"breakIt()\">Break it</button>\r\n    <button onclick=\"toggleSource()\">Toggle source</button>\r\n    <button onclick=\"removeTwoLayers()\">Remove two layers</button>\r\n  </body>\r\n</html>\r\n```"},"comment":{"url":"https://api.github.com/repos/openlayers/ol3/issues/comments/171589871","html_url":"https://github.com/openlayers/ol3/issues/4671#issuecomment-171589871","issue_url":"https://api.github.com/repos/openlayers/ol3/issues/4671","id":171589871,"user":{"login":"albertov","id":865291,"avatar_url":"https://avatars.githubusercontent.com/u/865291?v=3","gravatar_id":"","url":"https://api.github.com/users/albertov","html_url":"https://github.com/albertov","followers_url":"https://api.github.com/users/albertov/followers","following_url":"https://api.github.com/users/albertov/following{/other_user}","gists_url":"https://api.github.com/users/albertov/gists{/gist_id}","starred_url":"https://api.github.com/users/albertov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertov/subscriptions","organizations_url":"https://api.github.com/users/albertov/orgs","repos_url":"https://api.github.com/users/albertov/repos","events_url":"https://api.github.com/users/albertov/events{/privacy}","received_events_url":"https://api.github.com/users/albertov/received_events","type":"User","site_admin":false},"created_at":"2016-01-14T09:48:09Z","updated_at":"2016-01-14T09:48:09Z","body":"This seems only to occur when \"Developer Tools\" are open."}}