다

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

· 2015-12-03 (목) 11:09:10 · 14766

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

<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();"> 

 

 

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

개발자팁

5,403건

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

+
분류 제목 글쓴이 날짜 조회
PHP 15-12-03 조회 3,113
Mobile 15-12-03 조회 1.5만
JavaScript 15-12-03 조회 1.8만
JavaScript 15-12-03 조회 3,923
PHP 15-12-02 조회 6,511
PHP 15-12-02 조회 4,173
PHP 15-12-02 조회 5,932
PHP 15-12-02 조회 3,243
PHP 15-12-01 조회 3,344
PHP 15-12-01 조회 2,593
PHP 15-12-01 조회 2,719
PHP 15-11-30 조회 3,978
PHP 15-11-30 조회 5,426
PHP 15-11-30 조회 3,414
PHP 15-11-29 조회 2,521
PHP 15-11-29 조회 2,733
PHP 15-11-29 조회 6,293
PHP 15-11-28 조회 2,590
PHP 15-11-28 조회 3,075
PHP 15-11-28 조회 7,310
PHP 15-11-27 조회 3,320
PHP 15-11-27 조회 3,437
PHP 15-11-27 조회 2,971
MySQL 15-11-26 조회 9,370
JavaScript 15-11-25 조회 3,263
PHP 15-11-25 조회 2,807
PHP 15-11-25 조회 2,744
PHP 15-11-25 조회 3,383
웹서버 15-11-25 조회 3,675
PHP 15-11-23 조회 7,602