全屏控制

openlayer 全屏控制

单击右上角的控件以全屏显示。再次单击它以退出全屏。

如果地图上没有按钮,则您的浏览器不支持全屏API

<!DOCTYPE html><html>

  <head>

    <title>Full Screen Control</title>

    <link rel="stylesheet" href="https://openlayers.org/en/v5.1.3/css/ol.css" type="text/css">

    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->

    <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>

    <style>

      .map:-moz-full-screen {

        height: 100%;

      }

      .map:-webkit-full-screen {

        height: 100%;

      }

      .map:-ms-fullscreen {

        height: 100%;

      }

      .map:fullscreen {

        height: 100%;

      }

      .ol-rotate {

        top: 3em;

      }

    </style>

  </head>

  <body>

    <div id="map" class="map"></div>

    <script>

      import Map from 'ol/Map.js';

      import View from 'ol/View.js';

      import {defaults as defaultControls, FullScreen} from 'ol/control.js';

      import TileLayer from 'ol/layer/Tile.js';

      import BingMaps from 'ol/source/BingMaps.js';

 

 

      var view = new View({

        center: [-9101767, 2822912],

        zoom: 14

      });

 

      var map = new Map({

        controls: defaultControls().extend([

          new FullScreen()

        ]),

        layers: [

          new TileLayer({

            source: new BingMaps({

              key: 'Your Bing Maps Key from http://www.bingmapsportal.com/ here',

              imagerySet: 'Aerial'

            })

          })

        ],

        target: 'map',

        view: view

      });

    </script>

  </body></html>

 

 

相关文章: