繁体   English   中英

从Google Maps v3移除tabindex

[英]Remove tabindex from google maps v3

我正在尝试从maps api的所有部分中删除tabindex,我已经尝试过这篇文章的答案:

google.maps.event.addListener(MAP, "tilesloaded", function(){
    [].slice.apply(document.querySelectorAll('#map a')).forEach(function(item) {
        item.setAttribute('tabindex','-1');
    });
})

但这是行不通的,我在一个简单的地图上尝试将其添加到应用程序中,因此这是简单的页面:

<!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: 50%;
      }
      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <input type="text">
    <div id="map"></div>
    <input type="text">
    <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>

如果您希望地图不具有交互性,那么使用静态地图API似乎是一个合理的选择

编辑:根据您的评论,如果您不希望非屏幕阅读器用户完全正常工作,则可以选择将地图插入<div aria-hidden="true">标记中,该标记应使屏幕阅读器无法读取它。 您还可以在地图上方添加“跳过地图”链接,以使键盘用户(无屏幕阅读器)绕过地图。

暂无
暂无

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

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