2017-03-19 2 views
-1

screenshot of a GoogleMaps frame
내 프로젝트의지도에 Google API를 사용해 보았습니다. 이제 사용자가 선택한 위치의 GPS 좌표를 가져 와서 Mysql에 저장해야합니다. 당신이 navigator.geolocation를 사용할 수있는 자바 스크립트에서GPS 위치 좌표 가져 오기

<!DOCTYPE html> 
<html> 
<head lang="en"> 
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=myKeyQ&libraries=places"></script> 
<title>Demo Maps</title> 
</head> 
<body> 
<iframe 
width="600" 
height="450" 
frameborder="0" style="border:0" 
src="https://www.google.com/maps/embed/v1/place?key=myKey 
&q=Space+Needle,Seattle+WA" allowfullscreen> 
</iframe> 
</body> 

</html> 

답변

1

<script> 
    function getLocation() { 
     if (navigator.geolocation) { 
      navigator.geolocation.getCurrentPosition(showPosition); 
     } else { 
      window.alert("Geolocation is not supported by this browser."); 
     } 
    } 
    function showPosition(position) { 
     window.alert("Latitude: " + position.coords.latitude + 
     "<br>Longitude: " + position.coords.longitude); 
    } 

    getLocation(); 
    </script> 
+0

고마워요 ... :) –

+0

@KrunalPanchbhaya 아니라 내 대답은 바로 가능으로 표시하십시오 경우 ... 방법을 볼 특징 여기 http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – scaisEdge

+0

이것은 현재 위치를 알아내는 것입니다. –

관련 문제