我在一个文件管理器Web浏览器中使用谷歌地图API显示谷歌地图(使用文件管理器Pro v16)。在MacOS High Sierra上,一切正常,但在另一台运行Sierra或El Capita的Mac上,当您用鼠标单击缩放按钮时,缩放按钮(出现在右下角的+和-按钮)没有响应。
如果您使用鼠标通过滑动来缩放,它会很好地工作。如果我将HTML从Web浏览器保存到.html文件并在Safari中打开,它会正常工作,但由于某些原因,缩放按钮在这些系统的Web浏览器中不会响应。我正在使用类似于下面的maps api文档中的基本示例进行测试(我正在添加api密钥,但已从示例代码中删除):
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
/* 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;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 8
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?callback=initMap"
async defer></script>
</body>
</html>
我没有在控制台中得到任何东西,所以在这一点上,我很难理解为什么在单击地图上的放大/缩小按钮时鼠标单击不起作用。