none
Multiple Tilesources in AJAX v7 RRS feed

  • Question

  • I'm using the Bing 7.0 control.

    I have two tile sources that I want to display on my base bing map. Each tile source works independent of each other on my bing map. (looks great!) However, I want to toggle them on and off as well as show them together. The first tile source is a custom base map. The second is a layer of buildings that I want to show on top of the first.

     

    Any suggestions?

     

    here's the my code:

     

     

    // Initialize Map
       
    var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),{credentials:"my bing key!", center:new Microsoft.Maps.Location(38.898748, -77.037684), zoom:15, mapTypeId:"r", opacity: 1});
                   
                                   
                    // Create the Tile Layer
                                   
                    var tileSource = new Microsoft.Maps.TileSource({uriConstructor: 'http://maps.ifmm.com/Layer_BaseMap/{quadkey}.png'});
                    var tilelayer = new Microsoft.Maps.TileLayer({ mercator: tileSource, opacity: 1 });
                   
                    map.entities.push(tilelayer);
                   
                    var tileSource = new Microsoft.Maps.TileSource({uriConstructor: 'http://maps.ifmm.com/Layer_Commercial/{quadkey}.png'});
                    var tilelayer = new Microsoft.Maps.TileLayer({ mercator: tileSource, opacity: 1 });

                    // Push Tile Layer to Map
                   
                    map.entities.push(tilelayer);

     


    Mark Burlinson
    • Split by tanoshimiModerator Tuesday, April 19, 2011 8:26 AM Off-topic post in closed thread
    • Moved by Ricky_Brundritt Friday, March 9, 2012 5:11 PM (From:Bing Maps: Map Control and Web services Development)
    Tuesday, April 19, 2011 1:40 AM

Answers

  • You can show/hid individual tile layers by setting the visible property of the tileOptions to either true or false.

    Alternatively, you can fade tilelayers from fully opaque to fully transparent using the opacity setting.

    See http://msdn.microsoft.com/en-us/library/gg427613.aspx for more details on both.


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Tuesday, April 19, 2011 8:29 AM
    Moderator