2017-01-08 3 views
0

openlayer 3.i에서 일부 오버레이를 추가했습니다. Ctrl + 마우스를 클릭하고 마우스를 드래그하여지도에서 직사각형 영역을 선택하면 해당 오버레이를 가져올 수 있습니다. 지역?Openlayer 3 직사각형 선택

답변

1

예, DragBox 요소로 가능합니다.

당신이 요소 선언이 방법 :

var dragBox = new ol.interaction.DragBox({ 
    condition: ol.events.condition.platformModifierKeyOnly 
}); 

그리고 당신은 당신의 기존지도에 상호 작용으로 추가 할 수 있습니다

map.addInteraction(dragBox); 

당신은 몇 가지 동작을 추가 할 경우가 가능하다 이벤트를 boxstart 및 boxend에게 호출하십시오.

dragBox.on('boxstart', function() { 
    // Your stuff when the box starts being drawn 
}); 
dragBox.on('boxend', function() { 
    // Your stuff when the box is already drawn 
}); 

자세한 정보는 OpenLayer 의 3 API :이 helpfull했다 https://openlayers.org/en/latest/examples/box-selection.html

+0

: http://openlayers.org/en/latest/apidoc/ol.interaction.DragBox.html

또한 여기에 박스 선택의 예를 살펴 수 있습니다 –

관련 문제