Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap navbar disappears using leaflet

I am having some difficulty integrating leaflet with Bootstrap. I am using a script that creates a collapsible left navbar. When I interact with the leaflet map, the bootstrap navbar disappears.

This seems to be a CSS conflict, but I can't seem to identify where to begin troubleshooting. Here is the jsfiddle followed by CSS: http://jsfiddle.net/6sSrE/. Notice that when clicking the map, the navbar disappears.

It would be helpful if another set of eyes could suggest a different direction to identify this problem. I would really like to use Bootstrap for this application, but I can't resolve the conflict.

html, body, #map {
height: 100%;
margin: 0;
}
   body .viewport {
  position: absolute;
  padding: 0;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
}

body .viewport .frame {
  position: absolute;
  width: 200%;
  height: 100%;
  top: 0;
  bottom: 0;
  left: 0; 
  padding: 0;
}

body .viewport .frame .navbar .navbar-inner {
  border-radius: 0;
  padding-left: 5px; 
}

body .viewport .frame .menu {
  height: 100%;
  /* background-color: #3D6AA2; */ 
}

body .viewport .frame .menu.collapse {
  float: left;
  height: 100% !important;
  width: auto; 
}

body .viewport .frame .menu.collapse.height {
  position: relative;
  height: 0;
  overflow: hidden;
  -webkit-transition: height 0.35s ease;
  -moz-transition: height 0.35s ease;
  -o-transition: height 0.35s ease;
  transition: height 0.35s ease; 
}

body .viewport .frame .menu.collapse.width {
  position: relative;
  width: 0;
  overflow: hidden;
  -webkit-transition: width 0.35s ease;
  -moz-transition: width 0.35s ease;
  -o-transition: width 0.35s ease;
  transition: width 0.35s ease; 
}

body .viewport .frame .menu.collapse.in.width {
  width: auto; 
}

body .viewport .frame .menu.collapse.in.height {
  height: auto; 
}

body .viewport .frame .menu .collapse-inner {
  position: relative;
  width: 250px;
  height: 100%; 
}

body .viewport .frame .menu .navbar .navbar-inner {
  text-align: center;
  color: grey;
  font-size: 1.2em;
  line-height: 38px; 
}

body .viewport .frame .menu .nav-stacked {
  padding: 0 10px; 
}

body .viewport .frame .view {
  width: 50%;
  height: 100%;
  overflow: hidden; 
}

body .viewport .frame .view .navbar .navbar-inner .btn-navbar {
  display: block;
  float: left; 
}

body .viewport .frame .view #map {
  margin: auto 15px;
  text-align: justify; 
}
like image 872
allthesignals Avatar asked Jan 20 '26 21:01

allthesignals


1 Answers

It looks like every time the map gets focused the webpage is moving 78 pixels down. (You might be able to find where this is happening and fix it.)

However I just came up with something quick that would adjust your navbar so that it would show up at the top of the page every time.

$(document).ready(function(){
    var margin = 78;
    $('#map').on('mousedown',function(){
        $('#navBar').css('margin-top',margin+'px');
    });  
    $('#map').blur(function(){
        margin = margin+78;
    }); 
});

Note: I also added a ID to your nav bar.

<div class="navbar navbar-inverse" id="navBar">

Here is an example, seems to work pretty good for now, but might be worth your time later to figure out why the page is being moved down.

http://jsfiddle.net/6sSrE/15/

like image 56
Trevor Avatar answered Jan 22 '26 13:01

Trevor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!