美文网首页
OpenLayers - Accessible Map(1) -

OpenLayers - Accessible Map(1) -

作者: yo208 | 来源:发表于2018-03-23 14:49 被阅读0次

    This page's map element has its tabindex attribute set to "0", that makes it focusable. To focus the map element you can either navigate to it using the "tab" key or use the skip link. When the map element is focused the + and - keys can be used to zoom in and out and the arrow keys can be used to pan.

    Clicking on the "Zoom in" and "Zoom out" buttons below the map zooms the map in and out. You can navigate to the buttons using the "tab" key, and press the "enter" key to trigger the zooming action.

    本例子主要涉及图层放大缩小相关:zoom 操作。

       var map = new ol.Map({
            layers: [
              new ol.layer.Tile({
                source: new ol.source.OSM()
              })
            ],
            target: 'map',
            controls: ol.control.defaults({
              attributionOptions: {
                collapsible: false
              }
            }),
            view: new ol.View({
              center: [0, 0],
              zoom: 2
            })
          });
    document.getElementById('zoom-out').onclick = function(){
        var view=map.getView();
        var zoom=view.getZoom();
        view.setZoom(zoom-1);
    };
     
    
    

    相关文章

      网友评论

          本文标题:OpenLayers - Accessible Map(1) -

          本文链接:https://www.haomeiwen.com/subject/kgspqftx.html