Career/Openlayers

[Openlayers] 오픈레이어스 Polygon 사용방법

AlexHouse 2023. 1. 19. 16:48
728x90

※ 물론, 오픈레이어스를 사용하기 위해서 상속을 받아야 된다.

(Obviously Before starting, You should inherit to use Openlayers)

 


Method

 

/* 여기안에는 그냥 배열 처리만 해줘도 사용 할 수 있다.  */
const polygon = new ol.geom.Polygon([]);

polygon.setCoordinates([[[120, 38],[120, 33],[126, 38] ,[126, 33]]]);

const polygonFeature = new ol.Feature(polygon);

 

 

polygon 사용하는 코드이다.

(This is a code for using polygon.)

 

만약 여러개의 폴리곤을 사용하고 싶으면

(if you wanna try a lot of polygon)

 

MultiPolygon을 사용하기 바란다.

(You use MultiPolygon in Openlayers)

 

 

 

좌표의 순서는 다음처럼 그려주는 것이 좋겠다.

(It's recommended to use like this the order of coordinates)

 

 

 

 

그럼 다음과 같이 사각형이 나온다.

(So you can see square as you can see)

 

 

 

 

그럼

(So)

 

 

좌표계를 배열로 감는것을 잊지마세요.

 

(and You should be careful when you use setCoordinates()

 

Don't forget surrounding array on your coordinate!)

 

 

 

 

폴리곤이 정상적으로 작동하는 것 을 확인 할 수 있다.
(You can see that polygon is going to working normally)

 

https://chocoboy.tistory.com/386

 

[Openlayers] 오픈레이어스 LineString 사용 방법

너무 간단해서 깜딱 놀랐다. '점' 찍어봤다면 이건 거의 3분 카레수준으로 해볼수 있을 것이다. Method const lineLayer = new ol.Feature ({ geometry: new ol.geom.LineString([[133, 38],[133, 55]]) }) 다음과 같이 설정해

chocoboy.tistory.com

 

https://chocoboy.tistory.com/385

 

[Openlayers] 오픈레이어스 Point 찍는 방법

최근들어 오픈레이어스를 많이 사용하게 되어가지고, 오픈레이어스 공부를 본의아니게 하게 되었다. Method 간단하게, 오픈레이어스의 구조를 설명해보자면 다음과 같은 구조로 이루어져 있다.

chocoboy.tistory.com

 


 

To be continue..

 

728x90