2012-12-04 4 views
0

geolocation.watchPosition API에 넣었습니다.하지만 브라우저에서 실행할 때지도가 전혀 표시되지 않습니다. 아무도이 문제를 해결할 수있는 방법을 알려주시겠습니까? 기존 errorMessage 기능으로geolocation.watchposition가 작동하지 않습니다. 제발 도와주세요

<script> 

if (navigator.geolocation) 
{ 
    function showPositionOnMap(position) 
    { 
     var point = new google.maps.LatLng(position.coords.latitude, 
     position.coords.longitude), 

     myOptions = { 
      zoom: 15, 
      center: point, 
      mapTypeId: google.maps.MapTypeId.ROADMAP 
     }, 

     mapDiv = document.getElementById("mapDiv"), 
     map = new google.maps.Map(mapDiv, myOptions), 
       marker = new google.maps.Marker({ 
      position: point, 
      map: map, 
      title: "You are here" 
      }); 
    } 

    var timeoutVal = 10 * 1000 * 1000; 
    navigator.geolocation.watchPosition(showPositionOnMap, errorMessage, 
    { 
     enableHighAccuracy: true, timeout: timeoutVal, maximumAge: 0 }); 
} 

else 
{ 
    alert("Geolocation is not supported by this browser"); 
} 

</script> 

답변

0

,이 코드는 잘 작동합니다. 아마도 브라우저가 허용하지 않았기 때문에 Geolocation을 차단하고있는 것 같습니다.

관련 문제