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

· 10년 전 · 560

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

<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에서 해주시기 바랍니다.

+
제목 글쓴이 날짜 조회
10년 전 조회 427
10년 전 조회 269
10년 전 조회 254
10년 전 조회 265
10년 전 조회 299
10년 전 조회 276
10년 전 조회 333
10년 전 조회 325
10년 전 조회 303
10년 전 조회 470
10년 전 조회 470
10년 전 조회 245
10년 전 조회 561
10년 전 조회 872
10년 전 조회 403
10년 전 조회 551
10년 전 조회 1,348
10년 전 조회 382
10년 전 조회 354
10년 전 조회 333
10년 전 조회 1,108
10년 전 조회 429
10년 전 조회 216
10년 전 조회 246
10년 전 조회 450
🐛 버그신고