<tfoot id='wUVwE'></tfoot>
      <bdo id='wUVwE'></bdo><ul id='wUVwE'></ul>

    1. <small id='wUVwE'></small><noframes id='wUVwE'>

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

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

        检索 Leaflet 的当前比例值

        时间:2023-08-08

            <tbody id='A87Dc'></tbody>
        1. <tfoot id='A87Dc'></tfoot>

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

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

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

                  本文介绍了检索 Leaflet 的当前比例值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  是否可以获取Leaflet组件当前的缩放值?

                  Is it possible to get the current scale value of the Leaflet component?

                  上图显示了我想通过某种方法检索的300 公里"或100 英里".现有文档仅显示如何使用特定选项添加比例控制:http://leafletjs.com/reference.html#control-scale

                  The image above shows "300 km" or "100 miles" that i would like to retrieve by a method. The existing documentation does only show how to add the scale control with specific options: http://leafletjs.com/reference.html#control-scale

                  推荐答案

                  在低缩放级别(当你看到世界的很大一部分时)小心缩放.

                  Be careful with the scale at low zoom levels (when you see a large portion of the world).

                  您看到的比例实际上对地图视图的中心水平线有效.地图的一角,它所在的位置,甚至有点不对劲!

                  The scale that you see is actually valid for the center horizontal line of your map view. It is even slightly wrong for the corner of the map, where it is placed!

                  如果您只是想在其他地方复制"该 visual 比例,您可以简单地创建另一个 Scale Control 并提取其 HTML 容器,而不是将其嵌入到您的地图中:

                  If you just want to "duplicate" that visual scale somewhere else, you could simply create another Scale Control and extract its HTML container instead of embedding it to your map:

                  document.getElementById("myNewContainerId").appendChild(
                      L.control.scale(options).onAdd(map)
                  );
                  

                  如果您想读取缩放控件的实际像素长度和文本,您可以通过内部 _mScale.style.width_mScale.innerHTML 属性检索它们的比例控制.如果您想要英制值而不是公制值,请将 _mScale 替换为 _iScale.

                  If you want to read the actual pixel length and text of the Scale Control, you could retrieve them through the internal _mScale.style.width and _mScale.innerHTML properties of the Scale Control. Replace _mScale by _iScale if you want the imperial values instead of the metric ones.

                  否则,如果您希望能够测量地图上两点之间的距离,您应该使用 myLatLng.distanceTo(otherLatLng) 方法,这将更加准确,因为它不仅会在 myLatLng 实际使用正确的比例纬度,但如果将其放置在不同的纬度,也可以纠正沿 otherLatLng 路径可能存在的不同比例.

                  Otherwise, if you want to be able to measure some distance between 2 points on the map, you should rather use the myLatLng.distanceTo(otherLatLng) method, which would be far more accurate, as it would not only use the correct scale at the myLatLng actual latitude, but also correct for the possible different scale along the path to otherLatLng if it is placed at a different latitude.

                  返回到使用 Haversine 公式计算的给定 LatLng 的距离(以米为单位).请参阅 维基百科上的说明

                  Returns the distance (in meters) to the given LatLng calculated using the Haversine formula. See description on wikipedia

                  这篇关于检索 Leaflet 的当前比例值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:地图上的传单固定大小圆圈 下一篇:将谷歌折线图放在传单弹出窗口中

                  相关文章

                  最新文章

                    <legend id='q5IlY'><style id='q5IlY'><dir id='q5IlY'><q id='q5IlY'></q></dir></style></legend>
                    • <bdo id='q5IlY'></bdo><ul id='q5IlY'></ul>

                  1. <small id='q5IlY'></small><noframes id='q5IlY'>

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

                      <tfoot id='q5IlY'></tfoot>