none
Removing TileLayer while tiles are loading RRS feed

  • Question

  • Hello,

    I've noticed some unexpected behavior while working with TileLayers.

    I was working with the interactive SDK at https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk#tileLayerQuadKey+JS 

    and I added the following lines of code at the end:

    setTimeout(function()
    {
        map.layers.remove(katrinaTileLayer);
    }, 5000);

    Once I run it and then start zooming into the map and panning immediately I can see that tiles that were loading while the layer was removed still ended up being rendered. Is there a way to cancel all tile requests in a layer?

    Here is what my map looked like once the layer was removed:

    

    Thursday, December 21, 2017 3:43 PM

Answers

  • Tile requests are stopped when the layer is removed. I think what you are seeing is as follows:

    When the map renders it generates local tiles and merges the base map tiles, custom tile layers and poly shape rendering into a single HTML5 canvas of a tile. These are then cached for performance when panning/zooming. Once you finishing panning/zooming, the tiles go through and refresh. If the a tile layer has been removed and you have moved the map around before removing it such that tiles have loaded in places, the cached tiles hat are outside of the view will still have the tile layer on the those tiles until those tiles are re-rendered which will happen after you pan/zoom to that area. As such, you will see the tile layer in areas it was previously loaded temporarily (~100ms, depending on how big the map/how many tiles need to be re-rendered).


    [Blog] [twitter] [LinkedIn]

    Friday, February 23, 2018 7:34 PM

All replies

  • I'm not able to reproduce this. It is possible that they may appear temporarily as the tiles are cached, but these generally are not rendered for much longer than few milliseconds. If they are staying rendered and not ever being removed can you provide some more details to help us reproduce this; which browser are you using?

    [Blog] [twitter] [LinkedIn]

    Thursday, December 28, 2017 8:04 PM
  • I'm using chrome. I was just able to reproduce it on the first attempt in chrome. Once I click RUN, I start panning and zooming. After the layer is removed I can still view tiles from the katrina layer. Regardless of how long I wait, the tiles remain. (Ex: I'm watching as I type this all out and they are not going away). Once I zoom in/out again or pan far enough away the cached tiles are successfully removed. However, if I happen to stay in the same area and don't zoom, the tiles will stay there. 
    Thursday, December 28, 2017 8:09 PM
  • Hi, 

    Is there any update on this?

    Friday, February 23, 2018 7:16 PM
  • Tile requests are stopped when the layer is removed. I think what you are seeing is as follows:

    When the map renders it generates local tiles and merges the base map tiles, custom tile layers and poly shape rendering into a single HTML5 canvas of a tile. These are then cached for performance when panning/zooming. Once you finishing panning/zooming, the tiles go through and refresh. If the a tile layer has been removed and you have moved the map around before removing it such that tiles have loaded in places, the cached tiles hat are outside of the view will still have the tile layer on the those tiles until those tiles are re-rendered which will happen after you pan/zoom to that area. As such, you will see the tile layer in areas it was previously loaded temporarily (~100ms, depending on how big the map/how many tiles need to be re-rendered).


    [Blog] [twitter] [LinkedIn]

    Friday, February 23, 2018 7:34 PM
  • I understand what you're saying. But the tiles that still have the images are not "outside of the view". In the screen shot above, the tiles are in my view. If I pan and zoom and leave those tiles in my view, they remain. It's not until I move away from that area and then come back that they refresh. 
    Friday, February 23, 2018 7:39 PM
  • Which browser are you using? I'm not able to reproduce this. 

    [Blog] [twitter] [LinkedIn]

    Monday, February 26, 2018 5:16 PM