【问题标题】:jquery ui dialog not appearing on page with Google Maps v3jquery ui 对话框没有出现在 Google Maps v3 的页面上
【发布时间】:2013-03-26 00:37:14
【问题描述】:

在某些版本的 iPad/iOS Safari 上使用与 Google 地图在同一页面上的 jQuery UI 对话框似乎存在问题。

以下代码显示了一个地图,其下方有一个链接。单击该链接应该会弹出一个基本的 jQuery UI 对话框。

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
<style type="text/css">
#mapcontainer {
    width:50%;
    height:300px;
}
</style>
</head>
<body>

<!-- ## Map Container ## -->
<div id="mapcontainer"></div>

<!-- ## Show Dialog ## -->
<a id="showdialog" href="#">Show Dialog</a>

<!-- ## Dialog ## -->
<div id="mydialog"></div>

<script type="text/javascript">
jQuery(function($){
    initMap();
    $('#showdialog').click(function(event){
        event.stopPropagation();
        $('#mydialog').dialog();
    });
});

function initMap() {
    if (google.maps != null && typeof google.maps === 'object') {
        var mapOptions = {
            zoom: 8,
            center: new google.maps.LatLng(-34.397, 150.644),
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById('mapcontainer'), mapOptions);
    }
}
</script>

</body>
</html>

它似乎在较新的桌面浏览器和 Android 设备(本机浏览器和 Chrome)上运行良好。然而,在 iPad (iOS 5.1.1 Safari) 上单击链接时没有任何反应。在 iOS 模拟器上,它在 iOS 6.1 中的 Safari 上似乎可以正常运行,但在 5.1 或更低版本中无法正常运行。

一种可能的解决方案似乎是在 css 中使用类似的东西来强制 3D 加速:

*:not(html) {
    -webkit-transform: translate3d(0, 0, 0);
}

但这似乎可能会在图形元素较多的页面上引起其他问题。

还有其他更安全的方法吗?

【问题讨论】:

    标签: jquery ios ipad jquery-ui google-maps-api-3


    【解决方案1】:
    .ui-dialog * {
        -webkit-transform: translate3d(0, 0, 0);
    }
    

    欢迎您。你拯救了我的一天。 =)

    【讨论】:

      猜你喜欢
      • 2014-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-05
      相关资源
      最近更新 更多