2013-01-11 6 views
0

이제이 문제와 관련된 몇 가지 항목을 보았습니다. 대부분 폭이 넓기 때문입니다. 그러나 코드에이 내용이 있습니다. 내가 토글 버튼을 누른 후Google지도가 PHONEGAP ANDROID 시뮬레이터에 표시되지 않습니다.

<!DOCTYPE html> 
<html> 
<head> 
    <title>MAP APPLICATION</title> 
    <meta name="viewport" content="user-scalable=no,initial-scale=1, maximum-scale=1,minimum-scale=1, width=device-width;" /> 
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=----MY KEY---&sensor=true"></script> 
    <script type="text/javascript" charset="utf-8" src="phonegap-1.9.0.js"></script> 
    <script type="text/javascript" charset="utf-8"> 

    // Wait for PhoneGap to load 
    // 
    document.addEventListener("deviceready", onDeviceReady, false); 

    var watchID = null; 

    // PhoneGap is ready 
    // 
    function onDeviceReady() { 
     // Update every 3 seconds 
     var options = { frequency: 3000, enableHighAccuracy: true }; 
     watchID = navigator.geolocation.watchPosition(onSuccess, onError, options); 
    } 



    // onSuccess Geolocation 
    // 
    function onSuccess(position) { 
      var element = document.getElementById('geolocation'); 
      element.innerHTML = 'Latitude: ' + position.coords.latitude  + '<br />' + 
          'Longitude: ' + position.coords.longitude  + '<br />' + 
          '<hr />'  + element.innerHTML; 

      var latLng = new google.maps.LatLng(position.coords.latitude,position.coords.longitude); 
      var mapOptions = { 
        center: latLng, 
        panControl: false, 
        zoomControl: true, 
        zoom: 16, 
        mapTypeId: google.maps.MapTypeId.ROADMAP 
      }; 
      var map = new google.maps.Map(document.getElementById('map_holder'),mapOptions); 
      var marker = new google.maps.Marker({ 
        position: latLng, 
        map: map 
      }); 
    }        


    // onError Callback receives a PositionError object 
    // 
    function onError(error) { 
     var errString = ''; 
     // Check to see if we have received an error code 
     if(error.code) { 
      // If we have, handle it by case 
      switch(error.code) { 
       case 1: // PERMISSION_DENIED 
       errString = 
       'Unable to obtain the location information ' + 
       'because the device does not have permission '+ 
       'to the use that service.'; 
       break; 
       case 2: // POSITION_UNAVAILABLE 
       errString = 
       'Unable to obtain the location information ' + 
       'because the device location could not be ' + 
       'determined.'; 
       break; 
       case 3: // TIMEOUT 
       errString = 
       'Unable to obtain the location within the ' + 
       'specified time allocation.'; 
       break; 
       default: // UNKOWN_ERROR 
       errString = 
       'Unable to obtain the location of the ' + 
       'device due to an unknown error.'; 
       break; 
      } 
     } 
     // Handle any errors we may face 
     var element = document.getElementById('map_holder'); 
     element.innerHTML = errString; 
    } 

    </script> 
    </head> 
    <body> 
    <p id="geolocation">Watching geolocation...</p> 
    <button id="btnWatchPosition" onclick="onDeviceReady();">TOGGLE</button> <br> 
    <div id="map_holder" width="100%" height="100%"></div> 
    </body> 
</html> 

좌표는, UP 보이고있다 ...하지만지도 내가 뭘 잘못, 게재하지 않습니다.

답변

0

이 줄을 제거하고 안드로이드 시뮬레이터에서 작동

<meta name="viewport" content="user-scalable=no,initial-scale=1, maximum-scale=1,minimum-scale=1, width=device-width;" /> 
(일식)
관련 문제