javascript - Google Maps API 信息窗口在 iOS 12 上不垂直滚动
问题描述
在 Google Maps JavaScript API 的文档中,有一个如何将信息窗口添加到标记的示例。
渲染时,似乎 google 添加overflow:auto
到了信息窗口容器中,这很棒!在 Chrome 的开发者工具中,我可以模拟从 iOS 设备查看页面,并且可以在信息窗口中垂直滚动。但是,当我从实际的 iOS 设备查看此页面时,我无法垂直滚动。
以下是相关代码的片段。
// This example displays a marker at the center of Australia.
// When the user clicks the marker, an info window opens.
function initMap() {
var uluru = {lat: -25.363, lng: 131.044};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: uluru
});
var contentString = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h1 id="firstHeading" class="firstHeading">Uluru</h1>'+
'<div id="bodyContent">'+
'<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' +
'sandstone rock formation in the southern part of the '+
'Northern Territory, central Australia. It lies 335 km (208 mi) '+
'south west of the nearest large town, Alice Springs; 450 km '+
'(280 mi) by road. Kata Tjuta and Uluru are the two major '+
'features of the Uluru - Kata Tjuta National Park. Uluru is '+
'sacred to the Pitjantjatjara and Yankunytjatjara, the '+
'Aboriginal people of the area. It has many springs, waterholes, '+
'rock caves and ancient paintings. Uluru is listed as a World '+
'Heritage Site.</p>'+
'<p>Attribution: Uluru, <a href="https://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">'+
'https://en.wikipedia.org/w/index.php?title=Uluru</a> '+
'(last visited June 22, 2009).</p>'+
'</div>'+
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var marker = new google.maps.Marker({
position: uluru,
map: map,
title: 'Uluru (Ayers Rock)'
});
marker.addListener('click', function() {
infowindow.open(map, marker);
});
}
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
<div id="map"></div>
<!-- Replace the value of the key parameter with your own API key. -->
<script async defer
src="https://maps.googleapis.com/maps/api/js?callback=initMap">
</script>
我已经阅读了一些似乎相关的 SO 问题:
但是这些解决方案并没有解决我的问题。如何使此内容在 iOS 12 及更高版本上可滚动?
更新:这似乎是 iOS 12 特有的问题。iOS 11 设备(iPhone 6s plus)能够垂直滚动。垂直滚动出现问题的所有其他(五台)设备均为 iOS 12 及更高版本。
解决方案
推荐阅读
- linux - How to reliably detect dropped netlink requests or responses
- selenium-webdriver - Katalon:使用 switchTo 和 waitForElementClickable 后无法单击对象
- javascript - Blur event cancels click event in Vue component
- asp.net-core - 身份在本地主机上工作正常,但在服务器上出现错误
- python - 使用adjustText避免标签重叠与Python王子对应分析
- python - 敌人.rect 不更新
- ios - 服务管理器未填充 ViewModel
- firebase - Firebase 通知中的权限
- node.js - 当我尝试使用 --depth 21 更新包时,NPM 崩溃
- indexing - h2 数据库支持前缀索引吗?