简体   繁体   English

Bootstrap Modal中的Google Maps。 平移/缩放鼠标手势不起作用

[英]Google Maps in Bootstrap Modal. Pan/zoom mouse gestures not working

I recently had the need to place a map in a bootstrap modal, which works fine except for the ability to pan and zoon with mouse interaction. 最近,我需要将地图放在自举程序模态中,除了可以通过鼠标交互进行平移和变形外,它还可以正常工作。 Panning by clicking and dragging the mouse, and zooming by using the mouse wheel does not seem to work. 通过单击和拖动鼠标进行平移,以及使用鼠标滚轮进行缩放似乎不起作用。

I have put up an example of the problem. 我举了一个问题的例子。 (I have only tested it in Chromium and Firefox, on Kubuntu) http://jsfiddle.net/nG9nu/ (我只在Kubuntu的Chromium和Firefox中对其进行了测试) http://jsfiddle.net/nG9nu/

   $("#myModal").on(
    'shown.bs.modal',

function () {

    var pos = new google.maps.LatLng(63.43, 10.39);
    var mapProp = {
        center: pos,
        zoom: 14,
        draggable: false,
        scrollwheel: false,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("mapCanvas"),
    mapProp);
    google.maps.event.trigger(map, "resize");
});

Any ideas what stops the mouse events to reach google maps? 有什么想法可以阻止鼠标事件到达Google地图吗? Or how to fix this particular problem? 或如何解决此特定问题?

I am very thankfull for all the help I can get :) 我非常感谢我所能提供的所有帮助:)

var mapProp = {
    center: pos,
    zoom: 14,
    draggable: false,
    scrollwheel: false,
    mapTypeId: google.maps.MapTypeId.ROADMAP
};

I can see 我可以看到

scrollWheel => false   
draggable => false

Of course it won't work : set them to 'true' 当然是行不通的:将它们设置为“ true”

See this fiddle : http://jsfiddle.net/nG9nu/1/ 看到这个小提琴: http : //jsfiddle.net/nG9nu/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM