홈>
오픈 레이어 클러스터 된 기능 . 사용자가 클러스터를 클릭 할 때 이벤트를 처리하고 있지만 사용자가 클릭 한 클러스터의 속성을 가져올 수 없습니다.
내 질문 :사용자가 클러스터를 클릭하면 클러스터에있는 기능을 열거하고 해당 속성에 액세스하려면 어떻게해야합니까?
내 코드는 다음과 같습니다 :
var source = new VectorSource({
features: features //here are my features
});
var clusterSource = new Cluster({
distance: 20,
source: source
});
var clusters = new VectorLayer({
source: clusterSource,
style: function(feature) { ... }
});
var raster = new TileLayer({
source: new OSM()
});
var map = new Map({
layers: [raster, clusters],
target: 'map',
view: new View({ center: [0, 0], zoom: 2})
});
map.on('click', function(event) {
map.forEachFeatureAtPixel(event.pixel, function(feature,layer) {
alert('found feature');
// here I am stuck. How can I access the properties in the features of the cluster ?
});
});
- 답변 # 1
트렌드
- OpenCv의 폴더에서 여러 이미지 읽기 (python)
- 파이썬 셀레늄 모든 "href"속성 가져 오기
- html - 자바 스크립트 - 클릭 후 변경 버튼 텍스트 변경
- git commit - 자식 - 로컬 커밋 된 파일에 대한 변경을 취소하는 방법
- JSP에 대한 클래스를 컴파일 할 수 없습니다
- javascript - 현재 URL에서 특정 div 만 새로 고침/새로 고침
- jquery - JavaScript로 현재 세션 값을 얻으시겠습니까?
- javascript - swiperjs에서 정지, 재생 버튼 추가
- JavaScript 변수를 HTML div에 '출력'하는 방법
- python - 문자열에서 특정 문자 제거
마이크 덕분에 작동하는 코드는 다음과 같습니다.