angular leaflet directive ::检查point是否为多边形

时间:2014-10-28 07:36:25

标签: angularjs leaflet

所以,我知道使用传单我可以检查点是否在多边形中(在我的情况下只是使用地图视图端口):

    map.getBounds().contains(marker);

但我无法弄清楚如何使用角度传单指令做同样的事情,我正在尝试:

    $scope.$on('leafletDirectiveMap.moveend',function (e, args) {
        leafletData.getMap().then(function(map){
            var bounds = map.getBounds();

            var marker = L.marker([51.5, -0.09]);

            var foo = bounds.contains(marker);
            console.log("foo");
            console.log(foo); // returns: Cannot read property 'lat' of undefined
            // another try:
            //map.getBounds.contains(marker);
        });
    });

1 个答案:

答案 0 :(得分:0)

在github上看了之后我想出来了

    $scope.$on('leafletDirectiveMap.moveend', function (event) {
        leafletData.getMap().then(function (map) {
            var bounds = map.getBounds();
            var foo = bounds.contains(L.latLng(51.5, -0.09));
            console.log("foo");
            console.log(foo);

        });
    });
相关问题