jQuery可调整大小无法与谷歌地图一起使用

布拉德·沃尔斯

我试图将google maps放置在屏幕底部的可调整大小的div中,但是它不想出现。

有没有人使用可通过Google地图调整大小的JQuery,发现在实现时遇到困难?

我希望它如何出现在页面上的视觉表示

到目前为止,我在这里有设置:小提琴

这是我当前的代码:

的HTML

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDmIz3c-nQR5BkM2WbFyoUwc94bLMc36Nw&sensor=false"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

  <div id="wrapper">
    <div class="n-resizable-topcontent">
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      <div> some text here </div>
      </div>
    <div class="resizable">
      <div class="ui-resizable-handle ui-resizable-n" id="ngrip"></div>
      <div class="maps" id="maps"></div>
      </div>
    </div>

的CSS

#wrapper {
  position: fixed;
  width: 100%;
  height: 100vh;
}

.n-resizable-topcontent {
  height: 70%;
  background-color: #0098ff;
  overflow:scroll;
}
.resizable {
  width: 100%;
  height: 30%;
  }
#ngrip {
  width: 100%;
  background-color: #ffffff;
  height: 8px;
  border: 1px solid #000000;
}

.maps {
  width: 100%;
  height: 100%;
  z-index: 9999;
}
#maps {
  max-width: none;
}

JS

$(".resizable").resizable({
    handles: {
    'n': '#ngrip'
    },
    resize: function( event, ui ) {
            // parent
        var parent = ui.element.parent();
        var parent_height = parent.height();

        // Get the min value of height or 70% of parent height
        // Get the max value of height or 30% of parent height
        var height = Math.min(ui.size.height, parent_height * 0.7);
        height = Math.max(height, parent_height * 0.3);

        // Set height for resizable element, and do not change top position.
        // Instead the previous element - content container - will be adjusted.
        ui.size.height = height;
        ui.position.top = 0;

        // make the content container's height 100% of parent, less .resizable
        ui.element.prev('.n-resizable-topcontent').height( parent_height - height );
    }
});

//maps

function initMap() {
  // Create a map object and specify the DOM element for display.
  var map = new google.maps.Map(document.getElementById('maps'), {
    center: {lat: -34.397, lng: 150.644},
    scrollwheel: false,
    zoom: 8
  });
}
地理编码

您没有调用该initMap函数。

更新的小提琴(initMap在加载API时调用

代码段:

#wrapper {
  position: fixed;
  width: 100%;
  height: 100vh;
}
.n-resizable-topcontent {
  height: 70%;
  background-color: #0098ff;
  overflow: scroll;
}
.resizable {
  width: 100%;
  height: 30%;
}
#ngrip {
  width: 100%;
  background-color: #ffffff;
  height: 8px;
  border: 1px solid #000000;
}
.maps {
  width: 100%;
  height: 100%;
  z-index: 9999;
}
#maps {
  max-width: none;
}
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDmIz3c-nQR5BkM2WbFyoUwc94bLMc36Nw&callback=initMap" async defer></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

<div id="wrapper">
  <div class="n-resizable-topcontent">
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
    <div>some text here</div>
  </div>
  <div class="resizable">
    <div class="ui-resizable-handle ui-resizable-n" id="ngrip"></div>
    <div class="maps" id="maps"></div>
  </div>
</div>
<script>
  $(".resizable").resizable({
    handles: {
      'n': '#ngrip'
    },
    resize: function(event, ui) {
      // parent
      var parent = ui.element.parent();
      var parent_height = parent.height();

      // Get the min value of height or 70% of parent height
      // Get the max value of height or 30% of parent height
      var height = Math.min(ui.size.height, parent_height * 0.7);
      height = Math.max(height, parent_height * 0.3);

      // Set height for resizable element, and do not change top position.
      // Instead the previous element - content container - will be adjusted.
      ui.size.height = height;
      ui.position.top = 0;

      // make the content container's height 100% of parent, less .resizable
      ui.element.prev('.n-resizable-topcontent').height(parent_height - height);
    }
  });

  //maps

  function initMap() {
    // Create a map object and specify the DOM element for display.
    var map = new google.maps.Map(document.getElementById('maps'), {
      center: {
        lat: -34.397,
        lng: 150.644
      },
      scrollwheel: false,
      zoom: 8
    });
  }
</script>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

jQuery可拖动和可调整大小在动态生成的元素中无法一起使用

来自分类Dev

可调整大小的IFrame,但不能与JQuery一起拖动

来自分类Dev

与地图一起使用

来自分类Dev

可调整大小的jQuery UI工具无法正常工作?

来自分类Dev

jQuery可调整大小无法正常工作

来自分类Dev

jQuery可调整大小无法正常工作

来自分类Dev

jQuery可调整大小无法与子类正常工作

来自分类Dev

jQuery可调整大小的奇怪行为

来自分类Dev

jQuery可调整大小的更改css

来自分类Dev

jQuery可调整大小的奇怪行为

来自分类Dev

in操作符如何与地图一起使用?

来自分类Dev

jQuery UI可调整大小-使用溢出来调整表列大小

来自分类Dev

使用jQuery可调整大小的处理程序附加和调整div的大小

来自分类Dev

无法调整图像大小以与jQuery File Upload一起使用

来自分类Dev

无法调整图像大小以与jQuery File Upload一起使用

来自分类Dev

jQuery UI可调整大小的固定大小表

来自分类Dev

在使用可调整大小的 Jquery 增加 div 的大小时如何滚动?

来自分类Dev

使控件可调整大小

来自分类Dev

JavaFx可调整大小

来自分类Dev

使控件可调整大小

来自分类Dev

jQuery可调整大小和可拖动无法同时工作

来自分类Dev

jQuery可调整大小的一个方向移动,并删除滚动条

来自分类Dev

jQuery可调整大小的方向向一个方向移动,并删除滚动条

来自分类Dev

无法设置其中包含可调整大小的映像的HStack

来自分类Dev

jQuery UI可调整大小未达到最大宽度

来自分类Dev

滚动后jQuery可调整大小的重定位句柄

来自分类Dev

jQuery可调整大小的触摸屏

来自分类Dev

jQuery UI可调整大小的扩展div

来自分类Dev

jQuery UI可拖动+可调整大小的包含问题

Related 相关文章

热门标签

归档