모바일웹에서 현재위치의 좌표 가져오기

· 10년 전 · 14511

<!-- 지도를 보이기 위한 라이브러리 포함하기 -->

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>

 

<script type="text/javascript">  

function loadPost() {

  if (!!navigator.geolocation) 

  {

    navigator.geolocation.getCurrentPosition(successCallback,errorCallback);  

  }

  else

  {

    alert("이 브라우저는 Geolocation를 지원하지 않습니다");

  }

}    

 

function errorCallback(error)

{

    alert(error.message);

}    

 

function successCallback(position) { 

        var lat = position.coords.latitude;

        var lng = position.coords.longitude;

        취득한 좌표로 추가 로직을 첨부하면 됩니다. 

}

</script>

<body onload="loadPost();"> 

 

 

|
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
PHP 10년 전 조회 3,996
PHP 10년 전 조회 2,776
PHP 10년 전 조회 3,340
PHP 10년 전 조회 2,602
PHP 10년 전 조회 2,301
PHP 10년 전 조회 2,351
PHP 10년 전 조회 2,563
PHP 10년 전 조회 2,297
PHP 10년 전 조회 2,516
PHP 10년 전 조회 3,072
PHP 10년 전 조회 2,746
PHP 10년 전 조회 2,711
PHP 10년 전 조회 3,151
PHP 10년 전 조회 2,841
Mobile 10년 전 조회 1.5만
JavaScript 10년 전 조회 1.8만
JavaScript 10년 전 조회 3,656
PHP 10년 전 조회 6,206
PHP 10년 전 조회 3,889
PHP 10년 전 조회 5,664
PHP 10년 전 조회 2,931
PHP 10년 전 조회 3,082
PHP 10년 전 조회 2,301
PHP 10년 전 조회 2,478
PHP 10년 전 조회 3,744
PHP 10년 전 조회 5,140
PHP 10년 전 조회 3,173
PHP 10년 전 조회 2,295
PHP 10년 전 조회 2,440
PHP 10년 전 조회 6,015