私はOpenLayers 4を使用し、ソースとしてol.source.Clusterを持つレイヤーを持っています。クラスタ化されたポイントをクリックすると、クラスタを構成する元のポイントの範囲を拡大したいと考えています。私の問題は、私がこれらのオリジナルのポイントをどこにも見つけることができないことです。OpenLayers 4 zoom to cluster
私はクラスタで使用する距離からエクステントを計算しようとしましたが、結果は満足できません。
クラスタポイントの背後にある元のポイントはどのように判断するのですか?
<html>
<head>
<title>Cluster</title>
<link rel="stylesheet" href="https://openlayers.org /en/v4.1.1/css/ol.css" type="text/css">
<script src="https://openlayers.org/en/v4.1.1/build/ol.js"></script>
</head>
<body>
<div id="map" class="map"></div>
<script>
var geojsonObject = {
'type': 'FeatureCollection',
'crs': {
'type': 'name',
'properties': {
'name': 'EPSG:3857'
}
},
'features': [{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [0, 0]
}
}, {
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [9, 9]
}
},{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [10, 10]
}
}]
};
var source = new ol.source.Vector({
features: (new ol.format.GeoJSON()).readFeatures(geojsonObject)
});
var clusterSource = new ol.source.Cluster({
source: source,
distance: 30
});
var layer = new ol.layer.Vector({
source: clusterSource
});
var select = new ol.interaction.Select({
layers: [layer]
});
var view = new ol.View({
center: [5, 5],
zoom: 20
});
var map = new ol.Map({
target: 'map',
layers: [new ol.layer.Tile({
source: new ol.source.OSM()
}),layer],
view: view
});
map.addInteraction(select);
var selectedFeatures = select.getFeatures();
selectedFeatures.on('add', function(event) {
// event.target only contains the clustered point
var feature = event.target.item(0);
});
</script>
</body>
</html>
をズームするしかし、それは私のすべての機能を与えるだろう
を行うことができ、選択した機能の機能で
ソース、私はちょうど1つのクラスター化されたポイント(私が選択したもの)を構成する機能を必要としています。私はとにかく答えを見つけ、将来の参考のために投稿します。 – user613068