none
Ajax7 Setting the heading of the map?? RRS feed

  • Question

  • Hi, has anyone successfully set the heading of a map with setView() ??

    No matter what value I set to heading, the map renders the same...

        var viewOpt = {
          center : new MM.Location('41.38089254491803', '-73.95815102255509'), 
          mapTypeId : MM.MapTypeId.auto,
          bounds : new MM.LocationRect.fromString('[LocationRect [Location 41.38095053496477,-73.95816911941111] 0.001517619475478682,0.001767144675298482]'),
          heading : 273.9017581819554,
          zoom : 19.167418480890657};
    
        map.setView(viewOpt);
    


    Jonathon
    • Moved by Ricky_Brundritt Friday, March 9, 2012 3:12 PM (From:Bing Maps: Map Control and Web services Development)
    Sunday, February 6, 2011 7:55 PM

Answers

  • And here's the dirty hack!

        var viewOpt = {
          center : new MM.Location('41.38089254491803', '-73.95815102255509'), 
          mapTypeId : MM.MapTypeId.auto,
          bounds : new MM.LocationRect.fromString('[LocationRect [Location 41.38095053496477,-73.95816911941111] 0.001517619475478682,0.001767144675298482]'),
          zoom : 19.167418480890657};
    
        map.setView(viewOpt);
    
        setTimeout('map.setView({heading : parseInt(273.9017581819554)});', 1000);
    


    Jonathon
    Sunday, February 6, 2011 8:14 PM

All replies

  • And here's the dirty hack!

        var viewOpt = {
          center : new MM.Location('41.38089254491803', '-73.95815102255509'), 
          mapTypeId : MM.MapTypeId.auto,
          bounds : new MM.LocationRect.fromString('[LocationRect [Location 41.38095053496477,-73.95816911941111] 0.001517619475478682,0.001767144675298482]'),
          zoom : 19.167418480890657};
    
        map.setView(viewOpt);
    
        setTimeout('map.setView({heading : parseInt(273.9017581819554)});', 1000);
    


    Jonathon
    Sunday, February 6, 2011 8:14 PM
  • Hi,

     

    Heading changes works correctly for me, when calling this :

    if (map.getMapTypeId() == Microsoft.Maps.MapTypeId.birdseye) {
       map.setView({ heading: newHeading });
    }
    

    With these four values for newHeading : 0, 90, 180 and 270.

     

    But calling this code when current zoom level is too low (I've tried with 5) doesn't work : the heading doesn't change (i.e. stay to 0 / north) after you zoomed in to 18 or 19.

    Seems like heading won't change if your current zoom level isn't already high enough to show an oblique view.

    Monday, February 7, 2011 9:52 AM