2017-10-06 19 views
0

クラスターの最小半径を設定するパラメーターはありますか? - ポイントやフィーチャのセットが最小距離以内にある場合、それらはクラスターを形成します。openlayers3でクラスターを形成するためにどのくらい密接な機能を構成する必要があるかを設定する方法

ol.source.Cluster()には2つのパラメータがありますが、期待通りに機能していないようです。

  • 距離:クラスタ間の最小距離(ピクセル単位)。デフォルトは20です。

  • エクステント:エクステントを表す数値の配列。[minx、miny、 maxx、maxy]。

答えて

0

"期待どおりに動作しないようです"とはっきりしていません。手段??どのように期待通りに動作しないのですか?

distanceプロパティol.source.Clusterは、距離の設定に基づいてオブジェクトをグループ化する時期をレイヤに通知します。クラスタ層を作成するときに変更できます。たとえば:

var locationSource = new ol.source.Vector({ 
    url: loc_url, 
    format: new ol.format.GeoJSON({ 
    defaultDataProjection :'EPSG:3857' 
    }), 
    loader: vectorLoader, 
    strategy: ol.loadingstrategy.all 
}); 

var LOCclusterSource = new ol.source.Cluster({ 
    distance: 5, 
    source: locationSource 
}); 

私は希望distanceので、グループ/クラスタオブジェクトを見つけるまで、私は通常、距離のオブジェクトを変更するには、地図上の右に見えます。

マップレイヤー上のグループオブジェクトの半径は、マップレイヤーのスタイル機能によって変更できます。スタイル関数の多くの例がスタックにここに存在します。

注:あなたは、異なる形状を持つことができます。ここ

は、それがグループ/クラスタオブジェクトであることを視覚的に明らかですので、私は、クラスタ/グループの半径を大きくするために使用するまでのハッキングの例では、マップレイヤー上のオブジェクトであります同じレイヤーでもスタイル機能を使用しています。 https://openlayers.org/en/latest/examples/regularshape.html

// Location Map Layer Properties 
var locLyrProps = { 
    "radius": 8, 
    "CORadius": 12, 
    "groupRadius": 10, 
    "borderWidth": 2, 
    "color": [0, 0, 0, 0.5], 
    "txtMaxRes": 20, 
    "txtOffsetY": -20 
}; 

var styleFunction = function() { 
    return function(feature,resolution) { 
    var style; 
    var props = locLyrProps; 
    var radius; 
    var lyrTyp; 
    var gotGroup = false; 
    var features = feature.get('features'); 

    if (features.length == 1) { //Individual map object because length = 1 
     style = new ol.style.Style({ //Square layer object 
     image: new ol.style.RegularShape({ 
      radius: radius, 
      points: 4, 
      angle: Math.PI/4, 
      fill: createFillStyle(feature), 
      stroke: createStrokeStyle(feature, resolution) 
     }), 
     text: createTextStyle(feature, resolution) 
     }); 
    } else { 
     var rad = props.radius; 
     if (features.length > 1) { //If cluster/group of features increase radius of group object so group objects stand out a bit 
     rad = props.groupRadius; //If cluster/group object is found, set cluster/group radius for it 
     gotGroup = true; 
     } 
     console.log('circle radius: ' + rad); 
     style = new ol.style.Style({ 
     image: new ol.style.Circle({ 
      radius: rad, 
      fill: createFillStyle(feature), 
      stroke: createStrokeStyle(feature, resolution, gotGroup) 
     }), 
     text: createTextStyle(feature, resolution, props, gotGroup) 
     }); 
    } 
    return [style]; 
    }; 
}; 
関連する問題