"예상대로 작동하지 않는 것 같습니다." 방법?? 어떻게 예상대로 작동하지 않습니까 ??
distance
ol.source.Cluster
속성은 거리 설정에 따라 개체를 그룹화 할시기를 알려줍니다. 클러스터 계층을 생성 할 때 변경할 수 있습니다. 예를 들어 : 내가 원하는 distance
그래서 그룹/클러스터 객체가 바로지도에 보면 찾을 때까지
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
});
나는 보통 거리 오브젝트를 변경합니다.
지도 레이어의 그룹 개체 반경은지도 레이어의 스타일 함수를 통해 변경할 수 있습니다. 스타일 함수의 많은 예가 스택에 있습니다.
참고 : 당신은 할 수 있습니다 다른 모양 그것이 그룹/클러스터 객체임을 시각적으로 분명 그래서 여기
내가 클러스터의 반경을 증가하는 데 사용하는 최대 해킹 예이다/그룹지도 상에 객체 같은 레이어에서도 스타일 기능을 사용합니다.
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];
};
};