【问题标题】:How to calculate pixels on latlng base: leaflet如何在 latlng 基础上计算像素:传单
【发布时间】:2015-09-18 19:07:38
【问题描述】:

我正在使用传单 api。用户在其中绘制折线和保存在变量中的纬度。

我一直在寻找一个传单函数,它假设采用纬度和计算像素。找到了 layerPoint 函数,但由于我对传单的了解不足,无法使用该函数。

我使用了两个变量来存储两个 latlng 参数,但不明白如何在 layerPoint 函数中使用它们。

脚本

var polyline = new L.Polyline([]);
            var aa;
            var bb;
            function getDist(e) {
                // New marker on coordinate, add it to the map
                // Add coordinate to the polyline
                polyline.addLatLng(e.latlng).addTo(map).bindPopup();
                var ccc = prompt('1st or 2nd');
                if (ccc == '1') { aa = e.latlng}
                else if (ccc == '2') { bb = e.latlng; convertIt();
                }
            }

            function convertIt(e)
            {
                var getit = e.latLngToPoint(latlng, map.getZoom());
            }

如果有人可以提供帮助,请帮忙。感谢您的宝贵时间

【问题讨论】:

    标签: leaflet angular-leaflet-directive dc.leaflet.js


    【解决方案1】:

    latLngToPoint 是L.Map 上的一个方法。您需要将latLng 作为参数传递给convertIt 函数,然后将return map.latLngToPoint(e) 传递给e 作为convertIt 的参数名称。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-20
      • 2014-04-18
      • 1970-01-01
      • 2018-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多