tiledownloadcomplete fires multiple times for same tile layer.
-
Thursday, July 05, 2012 9:56 PM
I'm wanting to load multiple tile layers in sequential order. In order to achieve this, I am loading each subsequent tile layer based on the previous layer's completion. It appears that for a custom tile layer, I am getting multiple tiledownload complete events for the same tilelayer. I have a sample code below that shows this behavior.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>TileLayer with options</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script> <script type="text/javascript"> var map = null; function getMap() { map = new Microsoft.Maps.Map(document.getElementById('myMap'), { credentials: 'Your Bing Maps Key' }); Microsoft.Maps.Events.addHandler(map, 'tiledownloadcomplete', addCustomTileLayer); } function addCustomTileLayer() { var options = { uriConstructor: 'http://www.microsoft.com/maps/isdk/ajax/layers/lidar/{quadkey}.png' }; var tileSource = new Microsoft.Maps.TileSource(options); var tilelayer = new Microsoft.Maps.TileLayer({ mercator: tileSource, opacity: 0.4, visible: true, zIndex: 1 }); map.setView({ center: new Microsoft.Maps.Location(48.03, -122.42), zoom: 11 }); map.entities.push(tilelayer); Microsoft.Maps.Events.addHandler(tilelayer, 'tiledownloadcomplete', customTileDownloadComplete); } function customTileDownloadComplete() { alert("custom tile layer complete"); } </script> </head> <body onload="getMap();"> <div id='myMap' style="position:relative; width:400px; height:400px;"></div> <div> </div> </body> </html>
All Replies
-
Friday, July 13, 2012 7:55 AMOwner
The tiledownloadcomplete event does not work as you expect it. This event will fire every time the map is moved and the tiles in view have finished loading. That's what the documentation says this event does. Why not just add all the layers to the map. You can set the order in which they are overlaid using zIndex.http://rbrundritt.wordpress.com
- Proposed As Answer by Richard_BrundrittMicrosoft Employee, Owner Friday, July 13, 2012 7:55 AM
- Marked As Answer by Richard_BrundrittMicrosoft Employee, Owner Friday, July 13, 2012 4:05 PM

