geolocation 내위지

geolocation 내위지

더시민 0 407 0

function check_location(){//커스텀 현위치


    // HTML5의 geolocation으로 사용할 수 있는지 확인합니다 
    if (navigator.geolocation) {
        
        // GeoLocation을 이용해서 접속 위치를 얻어옵니다
        navigator.geolocation.getCurrentPosition(function(position) {
            
            var lat = position.coords.latitude, // 위도
                lon = position.coords.longitude; // 경도
            var g5_lat =  position.coords.latitude,
                g5_lon = position.coords.longitude; // 경도
                
            var g5_latFixed = g5_lat.toFixed(6),
                g5_lonFixed = g5_lon.toFixed(5);        
                document.write(g5_lat);
                document.write(g5_lon);
                document.write(g5_latFixed);
                document.write(g5_lonFixed);
            //alert("lat = "+lat+" lon = "+lon);

                         
          });
        
    } else { // HTML5의 GeoLocation을 사용할 수 없을때 마커 표시 위치와 인포윈도우 내용을 설정합니다
        
    alert('geolocation을 사용할수 없어요..');
        
    }
    
}

    //$(document).ready(function(){
   check_location();
   console.log(String(g5_lat) +" : "+String(g5_lon));
  //  });

0 Comments
제목
Category
Facebook Twitter GooglePlus KakaoStory KakaoTalk NaverBand