none
Show custom tile layer if in set location RRS feed

  • Question

  • Hi,

    I want to use a customtilesource if in a set location (bounding box) and at set zoom levels. I know I can add a button to add the tilesource but it would be far more elegant to add it automatically. Has anyone accomplished this? If so how?

    Also is it possible to add custom layers in to the default map styles dropdown and use the Automatic option that way?

    Thanks for the help in advance,

    Michael


    Web Developer MCTS SharePoint 2007 Developer
    • Moved by Ricky_Brundritt Saturday, March 10, 2012 10:07 AM (From:Bing Maps: Map Control and Web services Development)
    Monday, July 11, 2011 11:16 AM

Answers

  • Attach a listener to the onViewChangeEnd event, which fires every time the map view changes. In the handler for that event, check the values of map.getCenter() and map.getZoom(), and toggle the visibility of your custom layer accordingly by setting the "visible" property in the TileLayerOptions http://msdn.microsoft.com/en-us/library/gg427613.aspx.

    THere are no supported methods to add your own custom map styles into the default dropdown list - you an hack them in there using DOM manipulation and CSS, or else just create your own map style dropdown.


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    • Marked as answer by MDraisey Monday, July 11, 2011 4:01 PM
    Monday, July 11, 2011 12:09 PM
    Moderator
  • Recommended option to add the custom map style would be to use showMapTypeSelector option to disable the default the map style selection combo. You can then create your own selector having custom styles. This is make sure, that your implementation does not breaks, if there is any DOM change in current map selector.
    MSFT
    Hemant Goyal
    • Marked as answer by MDraisey Monday, July 11, 2011 4:01 PM
    Monday, July 11, 2011 3:56 PM

All replies

  • Attach a listener to the onViewChangeEnd event, which fires every time the map view changes. In the handler for that event, check the values of map.getCenter() and map.getZoom(), and toggle the visibility of your custom layer accordingly by setting the "visible" property in the TileLayerOptions http://msdn.microsoft.com/en-us/library/gg427613.aspx.

    THere are no supported methods to add your own custom map styles into the default dropdown list - you an hack them in there using DOM manipulation and CSS, or else just create your own map style dropdown.


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    • Marked as answer by MDraisey Monday, July 11, 2011 4:01 PM
    Monday, July 11, 2011 12:09 PM
    Moderator
  • Recommended option to add the custom map style would be to use showMapTypeSelector option to disable the default the map style selection combo. You can then create your own selector having custom styles. This is make sure, that your implementation does not breaks, if there is any DOM change in current map selector.
    MSFT
    Hemant Goyal
    • Marked as answer by MDraisey Monday, July 11, 2011 4:01 PM
    Monday, July 11, 2011 3:56 PM
  • Thanks guys. Two good answers - time to code them up.

    Michael


    Web Developer MCTS SharePoint 2007 Developer
    Monday, July 11, 2011 4:01 PM
  • Hi,

    Sorry to resurrect this thread. I've been searching high and low (very low) for an example of a custom map style dropdown for Bing Maps Ajax v7 - can someone point me in the right direct. Sorry!


    Web Developer MCTS SharePoint 2007 Developer
    Wednesday, July 20, 2011 3:13 PM
  • You just need to create a set of buttons/links that call the setOptions() method of the map to change the map style. e.g. Have a button that says "Road" that calls map.setView({mapTypeId : Microsoft.Maps.MapTypeId.road}); and a button that says "Aerial" that calls map.setView({mapTypeId : Microsoft.Maps.MapTypeId.road});

    Then style the set of buttons and/or add a dropdown effect using CSS/JS.


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Wednesday, July 20, 2011 5:33 PM
    Moderator