如何在Azure Maps中获取地图视图范围内的所有可见点

我一直在搜索并尝试使用多边形示例中的选择点示例,但是我并未绘制新的多边形,而是在地图中已经存在一个多边形以用作选择边界。我在地图上也有很多点,但是由于缩放比例,有些点不可见或可能隐藏了,因此即使它们位于选择多边形中,我也希望忽略所有这些点。这可能吗?

// searchArea is populated by click method
    function searchPolygon(searchArea) {
        var visiblePointsonly = ???;
        var poly = searchArea.toJson(); // This is failing saying toJson not a function?

        // Calculate all points that are within the polygon area.
        var ptsWithin = turf.pointsWithinPolygon(visiblePointsonly,poly);

        return ptsWithin;
    }

TIA! 里克...

zhanglijulia 回答:如何在Azure Maps中获取地图视图范围内的所有可见点

我设法弄清楚了……可能不是最好的,但它确实满足了我的需要!

function searchPolygon(searchArea) {
    // Get points visible on map
    var points = pointLayer.getSource();

    if(points){
        var poly = searchArea.shapes[0].toJson();
        points = points.shapes[0].toJson();

        // Calculate all points that are within the polygon area.
        var ptsWithin = turf.pointsWithinPolygon(points,poly);
    }

    return ptsWithin;
}

希望这会帮助需要相同功能的其他人, 干杯! 里克...

本文链接:https://www.f2er.com/2424529.html

大家都在问