Leaflet: ํด๋ฆฌ๊ณค๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉ๋œ getLatLngs๋Š” ๋ฐฐ์—ด์„ ๋ฐ˜ํ™˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์— ๋งŒ๋“  2016๋…„ 12์›” 23์ผ  ยท  4์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: Leaflet/Leaflet

๋ฒˆ์‹ ๋ฐฉ๋ฒ•

๋‚ด๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ์ „๋‹จ์ง€ ๋ฒ„์ „: 1.0.2
์‚ฌ์šฉ ์ค‘์ธ ๋ธŒ๋ผ์šฐ์ €(๋ฒ„์ „ ํฌํ•จ): Chrome ๋ฐ FF
์‚ฌ์šฉ ์ค‘์ธ OS/ํ”Œ๋žซํผ(๋ฒ„์ „ ํฌํ•จ): Windows 10

๋‚ด๊ฐ€ ๊ธฐ๋Œ€ํ•˜๋Š” ํ–‰๋™๊ณผ ๋‚ด๊ฐ€ ๋ณด๊ณ  ์žˆ๋Š” ํ–‰๋™

ํด๋ฆฌ๊ณค๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉ๋œ getLatLngs๋Š” ๋ฐฐ์—ด์„ ๋ฐ˜ํ™˜ํ•˜์ง€ ์•Š์ง€๋งŒ LatLngs๋Š” ๋ฌธ์ž์—ด๋กœ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. LatLng์˜ ํด๋ฆฌ๋ผ์ธ ๋ฐฐ์—ด๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋ฉด ๋ฐ˜ํ™˜๋ฉ๋‹ˆ๋‹ค. ์ด๊ฒƒ์€ 0.7.7 ๋ฒ„์ „์—์„œ ์ž˜ ์ž‘๋™ํ–ˆ์Šต๋‹ˆ๋‹ค.

๋ฌธ์ œ๋ฅผ ์žฌํ˜„ํ•˜๋Š” ์ตœ์†Œํ•œ์˜ ์˜ˆ

var latlngs = [
    [45.51, -122.68],
    [37.77, -122.43],
    [34.04, -118.2]
    ];
var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map);
alert(polyline.getLatLngs().length);

var polygon = L.polygon([
    [51.509, -0.08],
    [51.503, -0.06],
    [51.51, -0.047]
    ]).addTo(map);
alert(polygon.getLatLngs().length);

http://playground-leaflet.rhcloud.com/ ๋˜๋Š” ์‚ฌ์ดํŠธ์™€ ๊ฐ™์€ ๋‹ค๋ฅธ jsfiddle ์‚ฌ์šฉ.

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

L.Polygon.getLatLngs() ์˜ ๋ฐ˜ํ™˜ ๊ฐ’์€ ์‚ฌ์‹ค ํ•œ ์š”์†Œ์˜ ๋ฐฐ์—ด์ž…๋‹ˆ๋‹ค.

์ด๊ฒƒ์€ https://github.com/Leaflet/Leaflet/pull/ ์ดํ›„ https://github.com/Leaflet/Leaflet/blob/b1c2e99c1faf5d7a518a3260c22eb920a7512945/src/layer/vector/Polygon.js#L106 ์—์„œ ์ˆ˜ํ–‰๋ฉ๋‹ˆ๋‹ค. LatLng ๋ชฉ๋ก์ด ์•„๋‹ˆ๋ผ ๋ง ๋ชฉ๋ก์ด ์žˆ๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. polygon.getLatLngs()[0] ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์™ธ๋ถ€(์œ ์ผํ•œ) ๋ง์˜ LatLng ๋ฅผ ์–ป์œผ์‹ญ์‹œ์˜ค.

๋ชจ๋“  4 ๋Œ“๊ธ€

jsfiddle์€ ์—ฌ๊ธฐ์— ์žˆ์Šต๋‹ˆ๋‹ค https://jsfiddle.net/qccxwp64/2/

L.Polygon.getLatLngs() ์˜ ๋ฐ˜ํ™˜ ๊ฐ’์€ ์‚ฌ์‹ค ํ•œ ์š”์†Œ์˜ ๋ฐฐ์—ด์ž…๋‹ˆ๋‹ค.

์ด๊ฒƒ์€ https://github.com/Leaflet/Leaflet/pull/ ์ดํ›„ https://github.com/Leaflet/Leaflet/blob/b1c2e99c1faf5d7a518a3260c22eb920a7512945/src/layer/vector/Polygon.js#L106 ์—์„œ ์ˆ˜ํ–‰๋ฉ๋‹ˆ๋‹ค. LatLng ๋ชฉ๋ก์ด ์•„๋‹ˆ๋ผ ๋ง ๋ชฉ๋ก์ด ์žˆ๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. polygon.getLatLngs()[0] ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์™ธ๋ถ€(์œ ์ผํ•œ) ๋ง์˜ LatLng ๋ฅผ ์–ป์œผ์‹ญ์‹œ์˜ค.

์ด๊ฒƒ์€ ๋ชจ๋“  ๊ฒƒ์„ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค. ๋Œ€๋‹จํžˆ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!

๊ณต์‹ ๋ฌธ์„œ http://leafletjs.com/reference-1.0.3.html#polyline -getlatlngs๊ฐ€ LatLng[] ์ด์™ธ์˜ ๊ฒƒ์„ ๋‚˜ํƒ€๋‚ด๋„๋ก ๋ณ€๊ฒฝ๋˜์–ด์•ผ ํ•˜์ง€ ์•Š์Šต๋‹ˆ๊นŒ?

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰