list.jsp
<select id="type">
<option value="Point">Point</option>
<option value="LineString">LineString</option>
<option value="Polygon">Polygon</option>
<option value="Circle">Circle</option>
<option value="None" selected>None</option>
</select>
list-js.jsp
//draw
var source;
var draw;
function openlayersDraw(){
$("#type").change(function(){
map.removeInteraction(draw);
addInteraction();
})
// Add over interaction that draw hull in a layer
source = new ol.source.Vector({ wrapX: false });
var vector = new ol.layer.Vector({
title : 'vector',
source: source, });
map.addLayer(vector); //vector layer add
}
function addInteraction() {
var value = $("#type").find("option:selected").val();
if (value !== 'None') {
draw = new ol.interaction.Draw({
source: source,
type: value
});
map.addInteraction(draw);
}
}
위의 selectbox에 따라 도형을 그릴수 있음
'gis > Openlayers' 카테고리의 다른 글
[Openlayers] wms 적용하기 (0) | 2022.02.17 |
---|---|
[Openlayers] vworld wmts, map, pin, polygon, circle 객체 올리기 (0) | 2022.02.17 |
[Openlayers] Openlayers4 맵지도 적용해보기 (0) | 2021.09.30 |