<bdo id='IRoiU'></bdo><ul id='IRoiU'></ul>
        <i id='IRoiU'><tr id='IRoiU'><dt id='IRoiU'><q id='IRoiU'><span id='IRoiU'><b id='IRoiU'><form id='IRoiU'><ins id='IRoiU'></ins><ul id='IRoiU'></ul><sub id='IRoiU'></sub></form><legend id='IRoiU'></legend><bdo id='IRoiU'><pre id='IRoiU'><center id='IRoiU'></center></pre></bdo></b><th id='IRoiU'></th></span></q></dt></tr></i><div id='IRoiU'><tfoot id='IRoiU'></tfoot><dl id='IRoiU'><fieldset id='IRoiU'></fieldset></dl></div>
        <legend id='IRoiU'><style id='IRoiU'><dir id='IRoiU'><q id='IRoiU'></q></dir></style></legend>
        <tfoot id='IRoiU'></tfoot>
      1. <small id='IRoiU'></small><noframes id='IRoiU'>

        我可以防止将传单地图平移出世界边缘吗?

        时间:2023-05-28

        <small id='kS0D8'></small><noframes id='kS0D8'>

          <i id='kS0D8'><tr id='kS0D8'><dt id='kS0D8'><q id='kS0D8'><span id='kS0D8'><b id='kS0D8'><form id='kS0D8'><ins id='kS0D8'></ins><ul id='kS0D8'></ul><sub id='kS0D8'></sub></form><legend id='kS0D8'></legend><bdo id='kS0D8'><pre id='kS0D8'><center id='kS0D8'></center></pre></bdo></b><th id='kS0D8'></th></span></q></dt></tr></i><div id='kS0D8'><tfoot id='kS0D8'></tfoot><dl id='kS0D8'><fieldset id='kS0D8'></fieldset></dl></div>
        • <tfoot id='kS0D8'></tfoot>

                <tbody id='kS0D8'></tbody>

            • <legend id='kS0D8'><style id='kS0D8'><dir id='kS0D8'><q id='kS0D8'></q></dir></style></legend>

                <bdo id='kS0D8'></bdo><ul id='kS0D8'></ul>
                1. 本文介绍了我可以防止将传单地图平移出世界边缘吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  有没有办法限制平移出世界边缘?在这张照片上,棕色是世界,灰色是空虚.我想让它不可能像这样平移.

                  Is there a way to limit panning out of the world's edge? On this picture, brown is the world, grey is emptiness. I want to make it impossible to pan like this.

                  推荐答案

                  Leaflet 允许您使用 maxBoundsViscosity 选项(值:0 到 1)控制地图抵抗被拖出边界的程度.将其设置为最大值将完全禁用拖出边界.

                  Leaflet allows you to control how much the map resists being dragged out of bounds with the maxBoundsViscosity option (value: 0 to 1). Setting it to maximum disables dragging out of bounds entirely.

                  var map = new L.Map('map', {
                    center: bounds.getCenter(),
                    zoom: 5,
                    layers: [osm],
                    maxBounds: bounds,
                    maxBoundsViscosity: 1.0
                  });
                  

                  此功能在 1.0.0 中可用.相关拉取请求 包括 一个工作示例:

                  This feature is available in 1.0.0. The relevant pull request includes a working example:

                  var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
                    osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
                    osm1 = L.tileLayer(osmUrl, {
                      maxZoom: 18,
                      attribution: osmAttrib
                    }),
                    osm2 = L.tileLayer(osmUrl, {
                      maxZoom: 18,
                      attribution: osmAttrib
                    }),
                    bounds = new L.LatLngBounds(new L.LatLng(49.5, -11.3), new L.LatLng(61.2, 2.5));
                  
                  var map1 = new L.Map('map1', {
                    center: bounds.getCenter(),
                    zoom: 5,
                    layers: [osm1],
                    maxBounds: bounds,
                    maxBoundsViscosity: 0.75
                  });
                  
                  var map2 = new L.Map('map2', {
                    center: bounds.getCenter(),
                    zoom: 5,
                    layers: [osm2],
                    maxBounds: bounds,
                    maxBoundsViscosity: 1.0
                  });
                  
                  var latlngs = L.rectangle(bounds).getLatLngs();
                  L.polyline(latlngs[0].concat(latlngs[0][0])).addTo(map1);
                  L.polyline(latlngs[0].concat(latlngs[0][0])).addTo(map2);

                  html,
                  body,
                  #map {
                    margin: 0;
                    padding: 0;
                    width: 100%;
                    height: 100%;
                  }

                  <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.0/dist/leaflet.css" />
                  <script src="https://unpkg.com/leaflet@1.0.0/dist/leaflet.js"></script>
                  
                  <h1>Left: Bouncy maxBounds. Right: Not bouncy.</h1>
                  
                  <div id="map1" style="float: left; width:45%; height: 80%;"></div>
                  <div id="map2" style="float: left; width:45%; height: 80%;"></div>

                  这篇关于我可以防止将传单地图平移出世界边缘吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何修复错误“编译失败:./node_modules/@react-leafl 下一篇:传单事件:如何传播到重叠层

                  相关文章

                  最新文章

                2. <small id='R3RRY'></small><noframes id='R3RRY'>

                    <bdo id='R3RRY'></bdo><ul id='R3RRY'></ul>

                  <tfoot id='R3RRY'></tfoot>

                  <legend id='R3RRY'><style id='R3RRY'><dir id='R3RRY'><q id='R3RRY'></q></dir></style></legend>

                    <i id='R3RRY'><tr id='R3RRY'><dt id='R3RRY'><q id='R3RRY'><span id='R3RRY'><b id='R3RRY'><form id='R3RRY'><ins id='R3RRY'></ins><ul id='R3RRY'></ul><sub id='R3RRY'></sub></form><legend id='R3RRY'></legend><bdo id='R3RRY'><pre id='R3RRY'><center id='R3RRY'></center></pre></bdo></b><th id='R3RRY'></th></span></q></dt></tr></i><div id='R3RRY'><tfoot id='R3RRY'></tfoot><dl id='R3RRY'><fieldset id='R3RRY'></fieldset></dl></div>