Loading views...
ol geoserver compass 성공

ol geoserver compass 성공

Date
Date
2020 Feb 27 0:0
Created by
Created by
Seonglae ChoSeonglae Cho
Created time
Created time
2023 Feb 28 12:39
Last edited by
Last edited by
Seonglae ChoSeonglae Cho
Last edited time
Last edited time
2023 Apr 15 16:53
Refs
Refs
notion image

성공!

 
 
 
SVG: Circle Arc
Interactive Circle Arc The only way to draw an arc of a circle (such as used in pie chart), is by using the path element with the A command. [see SVG Path: Elliptical Arc] The path A command is not easy to understand.
  • 메인 참고 svg 로 그려야겠다는 아이디어 얻음
Use SVG icon as marker in OpenLayers
Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question. Provide details and share your research! Asking for help, clarification, or responding to other answers. Making statements based on opinion; back them up with references or personal experience. To learn more, see our tips on writing great answers.
Use SVG icon as marker in OpenLayers
  • 이거는 svg text로 ol source 사용하는 법
How to convert the html object to string type?
Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question. Provide details and share your research! Asking for help, clarification, or responding to other answers. Making statements based on opinion; back them up with references or personal experience. To learn more, see our tips on writing great answers.
How to convert the html object to string type?
  • 이거는 어째 component string 으로 하나 outerHTML 간단스키
setAttributeNS xmlns of for a general-purpose library
It appears web browsers throw a DOMException when one uses setAttributeNS on a element to set the xmlns attribute. i.e. >>> s = document.createElementNS('http://www.w3.org/2000/svg', 'svg') ​ ​ >>> s.setAttributeNS(null, 'xmlns', '123') Uncaught DOMException: Failed to execute 'setAttributeNS' on 'Element': '' is an invalid namespace for attributes.
setAttributeNS xmlns of for a general-purpose library
  • 당황한 부분인데 attrribute xmlns 주기가 안되길래 검색해보니 요거
 
drawCompass = (coor) => { // round Area feature = new ol.Feature({ geometry: coor }) feature.setStyle(styles.circleAlpha) correctionLayer.getSource().addFeature(feature) // Compass let arc = arcSVG(COMP_RAD,COMP_RAD,COMP_RAD/2,COMP_RAD/2,30,170,164) let svg = makeSVGbyPath(arc, COMP_RAD) console.log('', svg) let img = new ol.style.Icon({ src: 'data:image/svg+xml;utf8,' + svg.outerHTML }) let arcStyle = new ol.style.Style({ image: img }) arcStyle.setZIndex(ZINDEX_SEL) feature = new ol.Feature({ geometry: coor }) feature.setStyle(arcStyle) correctionLayer.getSource().addFeature(feature) }

Compass 전체 그리는 부분

 
 
makeSVGbyPath = (path, radius) => { let svg = document.createElement("svg") svg.appendChild(path) svg.setAttributeNS(null, 'style', `stroke:rgb(37, 51, 99); fill:none; stroke-width:2`) svg.setAttributeNS(null, 'width', `${radius*2}`) svg.setAttributeNS(null, 'height', `${radius*2}`) svg.setAttributeNS(null, 'version', "1.1") svg.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns', 'http://www.w3.org/2000/svg') return svg }

SVG를 Path 로 그리는 부분

 
arcSVG = (cx,cy,rx,ry, t1, angle, radian ) => { angle = angle % (2*π); let rotMatrix = f_rotate_matrix (radian); let [sX, sY] = ( f_vec_add ( f_matrix_times ( rotMatrix, [rx * cos(t1), ry * sin(t1)] ), [cx,cy] ) ) let [eX, eY] = ( f_vec_add ( f_matrix_times ( rotMatrix, [rx * cos(t1+angle), ry * sin(t1+angle)] ), [cx,cy] ) ) let fA = ( ( angle > π ) ? 1 : 0 ) let fS = ( ( angle > 0 ) ? 1 : 0 ) let path_2wk2r = document. createElementNS("http://www.w3.org/2000/svg", "path") path_2wk2r.setAttribute("d", "M " + sX + " " + sY + " A " + [ rx , ry , radian / (2*π) *360, fA, fS, eX, eY ].join(" ")) return path_2wk2r; }

이거는 메인 참고에서 가져온 svg arc 그려주는 함수

 
 
 
 
 
 
 
 
 

Recommendations