none
Bing Map V8 options RRS feed

  • Question

  • Bing map v8 options has been extended with

    navigationBarMode: Microsoft.Maps.NavigationBarMode

    navigationBarOrientation: Microsoft.Maps.NavigationBarOrientation

    both undefined when map is created

    Is there another way to get these?

    Thursday, July 7, 2016 9:11 AM

Answers

  • These are available when the map is being loaded. Here is an example: http://www.bing.com/api/maps/sdk/mapcontrol/isdk#compactNavigationBar+JS

    It does however look like the orientation is ignored if using the compact navigation bar. I'll have the developers look into this to see if it is by design or not.


    [Blog] [twitter] [LinkedIn]


    Thursday, July 7, 2016 5:26 PM
  • Oh, ok, misunderstood the issue. This is to be expected as getOptions generally returns the options that you have set. I'll see if this is something we can change since the navigation bar does automatically change depending on where the map is being rendered (i.e. compact is often displayed when the map is loaded on a smaller device).

    [Blog] [twitter] [LinkedIn]

    Friday, July 8, 2016 5:09 PM
  • Good news, the team has updated the experimental branch with fix for this. This will be rolled into the main release branch in early September. The navigation bar mode/orientation values are now set with the value used by the map, unless you set them, in which case your setting would be returned. Since these are enumerator values, printing them out will just display a number. You can do a comparison against the enumerator values if you want to display a more user friendly name. Here is a code sample:

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
    	credentials: 'Your Bing Maps Key'
    });	
    	
    var o = map.getOptions();
    
    var mode, orientation;
    
    switch(o.navigationBarMode){
    	case Microsoft.Maps.NavigationBarMode.default:
    		mode = 'default';
    		break;
    	case Microsoft.Maps.NavigationBarMode.compact:
    		mode = 'compact';
    		break;
    	case Microsoft.Maps.NavigationBarMode.minified:
    		mode = 'minified';
    		break;
    }
    
    switch(o.navigationBarOrientation){
    	case Microsoft.Maps.NavigationBarOrientation.horizontal:
    		orientation = 'horizontal';
    		break;
    	case Microsoft.Maps.NavigationBarOrientation.vertical:
    		orientation = 'vertical';
    		break;
    }
    	
     document.getElementById('printoutPanel').innerHTML = 
     '<b>navigationBarMode:</b> <br>' + mode + '<br>' +
     '<b>navigationBarOrientation:</b><br>' + orientation; 


    [Blog] [twitter] [LinkedIn]


    Wednesday, August 10, 2016 8:48 PM

All replies

  • These are available when the map is being loaded. Here is an example: http://www.bing.com/api/maps/sdk/mapcontrol/isdk#compactNavigationBar+JS

    It does however look like the orientation is ignored if using the compact navigation bar. I'll have the developers look into this to see if it is by design or not.


    [Blog] [twitter] [LinkedIn]


    Thursday, July 7, 2016 5:26 PM
  • Hello Ricky,

    please try code below


    var map = new Microsoft.Maps.Map(document.getElementById('myMap'));
    var o = map.getOptions();
    document.getElementById('printoutPanel').innerHTML = '<b>navigationBarMode:</b> <br>' + o.navigationBarMode + '<br>';
    document.getElementById('printoutPanel').innerHTML += '<b>navigationBarOrientation:</b> <br>' + o.navigationBarOrientation;

    Friday, July 8, 2016 7:18 AM
  • Oh, ok, misunderstood the issue. This is to be expected as getOptions generally returns the options that you have set. I'll see if this is something we can change since the navigation bar does automatically change depending on where the map is being rendered (i.e. compact is often displayed when the map is loaded on a smaller device).

    [Blog] [twitter] [LinkedIn]

    Friday, July 8, 2016 5:09 PM
  • Is there a property that indicates if map is running on "smaller device"?


    Tuesday, July 12, 2016 10:07 AM
  • There is no property that indicates this. This logic occurs server side. I am however having the devs looking into expose the navbar settings for the map which would allow you to determine which navbar is being displayed.

    [Blog] [twitter] [LinkedIn]



    Tuesday, July 12, 2016 6:00 PM
  • Good news, the team has updated the experimental branch with fix for this. This will be rolled into the main release branch in early September. The navigation bar mode/orientation values are now set with the value used by the map, unless you set them, in which case your setting would be returned. Since these are enumerator values, printing them out will just display a number. You can do a comparison against the enumerator values if you want to display a more user friendly name. Here is a code sample:

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
    	credentials: 'Your Bing Maps Key'
    });	
    	
    var o = map.getOptions();
    
    var mode, orientation;
    
    switch(o.navigationBarMode){
    	case Microsoft.Maps.NavigationBarMode.default:
    		mode = 'default';
    		break;
    	case Microsoft.Maps.NavigationBarMode.compact:
    		mode = 'compact';
    		break;
    	case Microsoft.Maps.NavigationBarMode.minified:
    		mode = 'minified';
    		break;
    }
    
    switch(o.navigationBarOrientation){
    	case Microsoft.Maps.NavigationBarOrientation.horizontal:
    		orientation = 'horizontal';
    		break;
    	case Microsoft.Maps.NavigationBarOrientation.vertical:
    		orientation = 'vertical';
    		break;
    }
    	
     document.getElementById('printoutPanel').innerHTML = 
     '<b>navigationBarMode:</b> <br>' + mode + '<br>' +
     '<b>navigationBarOrientation:</b><br>' + orientation; 


    [Blog] [twitter] [LinkedIn]


    Wednesday, August 10, 2016 8:48 PM