{"id":11489,"date":"2026-02-01T14:05:59","date_gmt":"2026-02-01T05:05:59","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=11489"},"modified":"2026-03-16T16:45:22","modified_gmt":"2026-03-16T07:45:22","slug":"javascript-%ed%9c%b4%eb%8c%80%ed%8f%b0-gps-%eb%a1%9c-%ed%98%84%ec%9e%ac%ec%9c%84%ec%b9%98-%ec%a1%b0%ed%9a%8c%ed%95%98%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=11489","title":{"rendered":"JavaScript &#8211; \ud734\ub300\ud3f0 GPS \ub85c \ud604\uc7ac\uc704\uce58 \uc870\ud68c\ud558\uae30"},"content":{"rendered":"<h1>JavaScript &#8211; \ud734\ub300\ud3f0 GPS \ub85c \ud604\uc7ac\uc704\uce58 \uc870\ud68c\ud558\uae30<\/h1>\n<p>\uc548\ub4dc\ub85c\uc774\ub4dc\ub098 \uc544\uc774\ud3f0\uc758 \ud06c\ub86c \ube0c\ub77c\uc6b0\uc800\ub294 \uc6f9 \ud45c\uc900 API\uc778 Geolocation API\ub97c \uc9c0\uc6d0\ud558\uae30 \ub54c\ubb38\uc5d0, \uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8\ub97c \uc0ac\uc6a9\ud574 \uc0ac\uc6a9\uc790\uc758 \uc704\ub3c4\uc640 \uacbd\ub3c4 \uc815\ubcf4\ub97c \uc2e4\uc2dc\uac04\uc73c\ub85c \uac00\uc838\uc62c \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<h2>GPS \uc815\ubcf4 \uac00\uc838\uc624\uae30<\/h2>\n<pre><code class=\"language-javascript\">if (&quot;geolocation&quot; in navigator) {\n  \/\/ \uc704\uce58 \uc815\ubcf4 \uac00\uc838\uc624\uae30 \uc2dc\ub3c4\n  navigator.geolocation.getCurrentPosition(\n    (position) =&gt; {\n      const lat = position.coords.latitude; \/\/ \uc704\ub3c4\n      const lon = position.coords.longitude; \/\/ \uacbd\ub3c4\n      console.log(`\uc704\ub3c4: ${lat}, \uacbd\ub3c4: ${lon}`);\n      alert(`\ud604\uc7ac \uc704\uce58 - \uc704\ub3c4: ${lat}, \uacbd\ub3c4: ${lon}`);\n    },\n    (error) =&gt; {\n      \/\/ \uc5d0\ub7ec \ucc98\ub9ac (\uad8c\ud55c \uac70\ubd80, \uc704\uce58 \ud655\uc778 \ubd88\uac00 \ub4f1)\n      console.error(&quot;\uc5d0\ub7ec \ubc1c\uc0dd: &quot; + error.message);\n    },\n    {\n      enableHighAccuracy: true, \/\/ \ub192\uc740 \uc815\ud655\ub3c4 \uc0ac\uc6a9 (GPS \uc6b0\uc120)\n      timeout: 5000,            \/\/ 5\ucd08 \uc548\uc5d0 \uc751\ub2f5 \uc5c6\uc73c\uba74 \uc5d0\ub7ec\n      maximumAge: 0             \/\/ \uce90\uc2dc\ub41c \uc704\uce58 \ub300\uc2e0 \ud56d\uc0c1 \uc0c8\ub85c \uce21\uc815\n    }\n  );\n} else {\n  alert(&quot;\uc774 \ube0c\ub77c\uc6b0\uc800\ub294 \uc704\uce58 \uc815\ubcf4\ub97c \uc9c0\uc6d0\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.&quot;);\n}<\/code><\/pre>\n<h2>\uae30\uc900\uc810\uacfc\uc758 \uac70\ub9ac \uacc4\uc0b0<\/h2>\n<p>\uc7a5\uac70\ub9ac\uac00 \uc544\ub2cc \ubc18\uacbd 1km \uc774\ub0b4\uc5d0\uc11c\uc758 \uac70\ub9ac\ub97c \uacc4\uc0b0\ud569\ub2c8\ub2e4.<br \/>\n\uae30\uc900\uc810\uc5d0 \uac00\uae4c\uc774 \uc788\ub294\uac00\ub9cc \uacc4\uc0b0\ud558\ub294 \uac83\uc744 \ubaa9\ud45c\ub85c \ud558\ubbc0\ub85c,<br \/>\n\uc6d0\uac70\ub9ac \uacc4\uc0b0\uc5d0\ub294 \ub2e4\ub978 \ub85c\uc9c1\uc744 \uc801\uc6a9\ud574\uc57c \ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-javascript\">function getPreciseDistance(lat1, lon1, lat2, lon2) {\n    const R_METERS = 6378137; \/\/ \uc9c0\uad6c \ubc18\uc9c0\ub984 (m)\n    const dLat = (lat2 - lat1) * Math.PI \/ 180;\n    const dLon = (lon2 - lon1) * Math.PI \/ 180;\n\n    \/\/ \ud3c9\uade0 \uc704\ub3c4\uc5d0 \ub300\ud55c \ucf54\uc0ac\uc778 \ubcf4\uc815\uac12 \uacc4\uc0b0\n    const cosLat = Math.cos((lat1 + lat2) \/ 2 * Math.PI \/ 180);\n\n    const x = dLon * R_METERS * cosLat;\n    const y = dLat * R_METERS;\n\n    return Math.sqrt(x * x + y * y); \/\/ \ub2e8\uc704: \ubbf8\ud130(m)\n}\n\n\/\/ \uc0ac\uc6a9 \uc608\uc2dc\nconst dist = getPreciseDistance(37.5665, 126.9780, 37.5668, 126.9783);\nconsole.log(`\ub450 \uc9c0\uc810 \uc0ac\uc774\uc758 \uac70\ub9ac: ${dist.toFixed(2)}m`);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript &#8211; \ud734\ub300\ud3f0 GPS \ub85c \ud604\uc7ac\uc704\uce58 \uc870\ud68c\ud558\uae30 \uc548\ub4dc\ub85c\uc774\ub4dc\ub098 \uc544\uc774\ud3f0\uc758 \ud06c\ub86c \ube0c\ub77c\uc6b0\uc800\ub294 \uc6f9 \ud45c\uc900 API\uc778 Geolocation API\ub97c \uc9c0\uc6d0\ud558\uae30 \ub54c\ubb38\uc5d0, \uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8\ub97c \uc0ac\uc6a9\ud574 \uc0ac\uc6a9\uc790\uc758 \uc704\ub3c4\uc640 \uacbd\ub3c4 \uc815\ubcf4\ub97c \uc2e4\uc2dc\uac04\uc73c\ub85c \uac00\uc838\uc62c \uc218 \uc788\uc2b5\ub2c8\ub2e4. GPS \uc815\ubcf4 \uac00\uc838\uc624\uae30 if (&quot;geolocation&quot; in navigator) { \/\/ \uc704\uce58 \uc815\ubcf4 \uac00\uc838\uc624\uae30 \uc2dc\ub3c4 navigator.geolocation.getCurrentPosition( (position) =&gt; { const lat = position.coords.latitude; \/\/ \uc704\ub3c4 const lon = position.coords.longitude;\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=11489\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-11489","post","type-post","status-publish","format-standard","hentry","category-web"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/11489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11489"}],"version-history":[{"count":3,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/11489\/revisions"}],"predecessor-version":[{"id":11492,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/11489\/revisions\/11492"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}