파

GPS정보 모바일에서 사용하기

· 2014-04-13 (일) 00:34:56 · 5732
 
모바일에서 GPS가져오는 파일입니다.
유용하게 사용하세요 안되시면 쪽지주세요..
구글플레이안산놀이터에 적용된 파일입니다.
 
 
<!DOCTYPE html>
<html>
 <head>
  <title>jQuery Mobile</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> 
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
<script type='text/javascript' src='/js/jquery-1.7.2.min.js'></script>
<script type='text/javascript' src='/js/jquery.common.js'></script>
<script type='text/javascript' src='/js/swipe.js'></script>
  <meta charset="utf-8" />
  <script>
    var geocoder = new google.maps.Geocoder();
    var addr = "";
   if( navigator.geolocation )
   {
    //괄호 속 인자 ( 성공일 때 함수명, 실패일 때 함수명)
    navigator.geolocation.getCurrentPosition( showPosition, handleError );
   }
   else
   {
    alert('navigator.geolocation 브라우저 미지원');
   }
   function showPosition( position )
   {
    //alert( '위도 : '+position.coords.latitude + '\n경도 : ' + position.coords.longitude );
    googl(position.coords.latitude,position.coords.longitude);
   }
   function handleError( evt )
   {
    alert( evt.message );
   }   
    function googl(num1, num2){
      var latlng = new google.maps.LatLng(num1, num2); 
     
      geocoder.geocode({'latLng': latlng}, function(results, status){
 
     if( status == google.maps.GeocoderStatus.OK ) { 
      //alert(results[0].formatted_address);
  
    //  document.write(results[1].formatted_address);
    //$("#add1").value('111');//results[1].formatted_address); 
    document.body.innerHTML = results[1].formatted_address;
   } 
   else { 
    //document.write("Geocoder failed due to: " + status)
    document.body.innerHTML += "Geocoder failed due to: " + status + "<br />";
    //$("#address").html("Geocoder failed due to: " + status);; 
   } 
  });
}
</script>
</head>
<body>
<!-- <div id="add1" style="font-size:13px;"></div> -->
</body>
</html>

첨부파일

gps.html (1.9 KB) 100회 2014-04-13 00:34
|
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,403건

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

+
분류 제목 글쓴이 날짜 조회
기타 14-05-13 조회 8,978
웹서버 14-05-13 조회 4,342
jQuery 14-05-11 조회 3,564
jQuery 14-05-11 조회 3,864
jQuery 14-05-11 조회 4,151
JavaScript 14-05-11 조회 4,288
MySQL 14-05-09 조회 3,458
JavaScript 14-05-09 조회 4,532
JavaScript 14-05-09 조회 1.1만
jQuery 14-05-09 조회 2만
기타 14-05-08 조회 5,008
기타 14-05-05 조회 1.2만
jQuery 14-05-01 조회 4,970
JavaScript 14-04-30 조회 3,601
PHP 14-04-30 조회 1.6만
기타 14-04-29 조회 2,829
PHP 14-04-27 조회 4,042
PHP 14-04-26 조회 4,271
JavaScript 14-04-25 조회 4,449
기타 14-04-25 조회 8,886
MySQL 14-04-22 조회 4,222
JavaScript 14-04-21 조회 2,831
JavaScript 14-04-21 조회 4,958
MySQL 14-04-16 조회 5,526
웹서버 14-04-16 조회 3,101
PHP 14-04-13 조회 5,733
PHP 14-04-13 조회 3,862
JavaScript 14-04-10 조회 4,072
기타 14-04-07 조회 4,627
JavaScript 14-04-01 조회 6,377