ol3 ext-ol如何使不同层的群集

时间:2019-03-06 20:18:51

标签: openlayers-3 layer

我在ol-ext中使用ol3 / ol4 我创建了两层:

clusterSource = new ol.source.Cluster({
    distance: distanceFt,
    source: new ol.source.Vector()
});
// Animated cluster layer
clusterLayer = new ol.layer.AnimatedCluster({
    name: 'Cluster',
    source: clusterSource,
    animationDuration: 700, //$("#animatecluster").prop('checked') ? 700 : 0,
    // Cluster style
    style: getStyle
});

layersArray.push(clusterLayer); // adding to array

sourceReclamos_Eventos = new ol.source.Cluster({
        distance: distanceFt,
        source: new ol.source.Vector()
    });
    capaReclamos_Eventos = new ol.layer.AnimatedCluster({
        name: "Reclamos_Eventos",
        source: sourceReclamos_Eventos,
        animationDuration: 700,
        style: getStyle
    });
    layersArray.push(capaReclamos_Eventos);

稍后,将该层添加到:

selectCluster = new ol.interaction.SelectCluster({
    layers: arraySelectCLuster,
    // Point radius: to calculate distance between the features
    pointRadius: 20,
    animate: true, //$("#animatesel").prop('checked'),
    // Feature style when it springs apart
    featureStyle: featureStyle,
    selectCluster: false,   // disable cluster selection
});

加载图层后,仅将要素保留在第一层中,在第二层中,更改缩放比例后将要素删除(清除)...为什么?

请帮助

编辑

我正在使用clusterLayer.getSource()。addFeatures()和capaReclamos_Eventos.getSource()。addFeatures()添加功能。

function addFeatures_Reclamos_Eventos(ffs, centrar) {
    var transform = ol.proj.getTransform('EPSG:4326', 'EPSG:3857');
    var features = [];
    for (var i = 0; i < ffs.length; i++) {
        features[i] = new ol.Feature();
        features[i].setProperties(ffs[i]);
        var geometry = new ol.geom.Point(transform([parseFloat(ffs[i].lon), parseFloat(ffs[i].lat)]));
        features[i].setGeometry(geometry);
    }
    qweFeature = features;
    capaReclamos_Eventos.getSource().addFeatures(features);
    removeloading('mapLoading');
    if (document.getElementById('botonFiltrar')) {
        document.getElementById('botonFiltrar').disabled = false;
    }
    if (centrar) {
        window.setTimeout(function () {
            var extent = capaReclamos_Eventos.getSource().getExtent();
            map.getView().fit(extent, map.getSize());
        }, 700);// 1/2 seg        
    }
}

0 个答案:

没有答案