U E D R , A S I H C RSS

html5/geolocation


1. Geolocation API?

  • ν”„λ‘œκ·Έλž¨μ„ μ‹€ν–‰ν•˜λŠ” λ””λ°”μ΄μŠ€μ˜ μœ„μΉ˜ 정보λ₯Ό μ–»κΈ° μœ„ν•œ API
  • λͺ¨λ°”일 μ• ν”Œλ¦¬μΌ€μ΄μ…˜κ³Ό μ—°λ™ν•˜μ—¬ μ‚¬μš©
  • κ³ κΈ‰ 레벨의 API - GPSλ₯Ό μ΄μš©ν•˜λŠ”μ§€ λ„€νŠΈμ›Œν¬ 정보λ₯Ό μ΄μš©ν•˜λŠ”μ§€λŠ” μ•Œμˆ˜ μ—†μœΌλ‚˜
    λ””λ°”μ΄μŠ€λ‚˜ λ„€νŠΈμ›Œν¬μ˜ μ’…λ₯˜μ— 관계없이 λ™μž‘!

2. μ‚¬μš© 방법

  • Geolocation API κ΄€λ ¨ λ©”μ„œλ“œλŠ” λͺ¨λ‘ window.navigator 객체에 μ •μ˜

2.1. getCurrentPosition()

  • ν˜„μž¬ μœ„μΉ˜λ₯Ό ν•œλ²ˆλ§Œ λ°›λŠ” λ©”μ„œλ“œ

   namigator.geolocation.getCurrentPosition(function(position){
     alert("μœ„λ„:" + position.coords.latitude +
        "경도 :" + position.coords.longitude);
   });
  • μœ„μΉ˜ 정보 객체의 속성
coords 속성섀λͺ…
latitudeμœ„λ„
longitude경도
altitudeν‘œκ³ 
accuracyμœ„λ„μ™€ κ²½λ„μ˜ 였차
altitudeAccuracyν‘œκ³ μ˜ 였차
headingμ§„ν–‰λ°©ν–₯
speedμ§„ν–‰ 속도

2.2. watchPosition()

  • ν˜„μž¬ μœ„μΉ˜λ₯Ό 계속 좔적
  • clearWatch()κ°€ 호좜되면 μ’…λ£Œ

3. μΆ”κ°€ κΈ°λŠ₯

속성섀λͺ…
enableHighAccuracy정확도가 높은 μœ„μΉ˜ 정보 μš”μ²­
timeoutμœ„μΉ˜ 정보 확인에 μ‹œκ°„μ œν•œ μ„€μ •
maximumAge유효 κΈ°κ°„ μ„€μ •

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:31:40
Processing time 0.0168 sec