Making the Bing Map API Map responsive

前端 未结 2 408
北恋
北恋 2021-01-14 18:44

I am using Bing Map API v7 and I am trying to make it responsive. My initial idea was the typical

相关标签:
2条回答
  • 2021-01-14 19:09

    I do it with map.SetView:

    addEvent(window, 'resize', function() { 
      var width = $(window).width();
      map.setView({ width: width, height: 400 })
    });
    
    0 讨论(0)
  • 2021-01-14 19:22

    You need to detect the window height with Javascript and then set the height dynamically on load as well as on resize. This is for Google map but it's the same premise.

    $(window).resize(function () {
    var screenH = $(document).height();
    var screenW = $(document).width();
    $('#map-canvas').css({
        width: screenW - listingsW,
    })
     google.maps.event.trigger(map, 'resize');
    
    });
    
    0 讨论(0)
提交回复
热议问题