首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >聚类过滤器geojson mapbox

聚类过滤器geojson mapbox
EN

Stack Overflow用户
提问于 2015-01-28 03:13:21
回答 1查看 517关注 0票数 0

我正在尝试调用通过过滤器转换为集群的my geojson文件,但它不起作用。我向过滤器"san pedro“应用警报,它起作用了,但集群被设置为活动的。在……里面

代码语言:javascript
复制
var marcadores = L.mapbox.featureLayer('geojson/todos.geojson').on('ready', function(e) {
        var clusterGroup1 = new L.MarkerClusterGroup();

        e.target.eachLayer(function(layer1) {
            clusterGroup1.addLayer(layer1);
        });
     mapa.addLayer(clusterGroup1);    
    });


    $('.menu-ui a').on('click', function() {
        var filter = $(this).data('filter');
        alert(filter);
        $(this).addClass('active').siblings().removeClass('active');
         marcadores.setFilter(function(f) {
         alert(filter === 'sanpedro');
            return (filter === 'all') ? true : f.properties[filter] === true;
        });
        return false;
    });
EN

回答 1

Stack Overflow用户

发布于 2015-02-07 07:00:42

你也必须更新它。

代码语言:javascript
复制
var marcadores = L.mapbox.featureLayer('geojson/todos.geojson');
var clusterGroup1 = new L.MarkerClusterGroup();
mapa.addLayer(clusterGroup1);
marcadores.on('ready', function(e) {
    clusterGroup1.clearLayers();
    e.target.eachLayer(function(layer1) {
        clusterGroup1.addLayer(layer1);
    });
});


$('.menu-ui a').on('click', function() {
    var filter = $(this).data('filter');
    alert(filter);
    $(this).addClass('active').siblings().removeClass('active');
     marcadores.setFilter(function(f) {
     alert(filter === 'sanpedro');
        return (filter === 'all') ? true : f.properties[filter] === true;
    });
    marcadores.fireEvent('ready');
    return false;
});
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28178204

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档