2013-08-21 3 views
1

정말 내 문제가 도움이되기를 바랍니다. 모바일 앱인 http://ufa-ld-qa.azurewebsites.net/ (QA 사이트)을 asp.net mvc4와 함께 사용하여 Bing Maps API를 사용하여 앱의 다양한 기능을 구현했습니다. 길 찾기 모듈에 문제가 있습니다. 내 PC (Chrome 및 IE)에서 사이트를 볼 때 정상적으로 작동하고 오류는 보이지 않지만 모바일 장치에서는 작동하지 않습니다 (하지만 어제 품질 보증을 시작했을 때 제대로 작동했습니다). HTML5 위치 정보 (문제 일 수 있음)를 사용하여 위치에 대한 길 찾기를 허용하도록 사용자의 위치를 ​​얻었습니다. 나는 아래에 내 코드를 게시 할 것이고 누군가 나를 기쁘게 해 주시면 큰 도움이 될 것입니다. 우리는 서로 다른 OS를 가진 약 7 개의 다른 모바일 장치에서이를 테스트했으며 어떤 장치에서도 작동하지 않습니다. 이것이 빙 문제인지 아래의 코드인지 아는 사람 있습니까? 미리 감사드립니다.빙지도 APi는 PC에서 작동하지만 모바일 웹 앱에서는 작동하지 않습니다.

<script type="text/javascript"> 
    var map = null; 
    var directionsManager = null; 
    var userLat = null; 
    var userLong = null; 
    var userPosition = null; 
    var latlng = new Microsoft.Maps.Location(@Model.latitude, @Model.longitude); 
    navigator.geolocation.getCurrentPosition(locationHandler); 

    function locationHandler(position) 
    { 

     userPosition = new Microsoft.Maps.Location(position.coords.latitude, position.coords.longitude); 
    } 
    function GetMap() { 

     // Initialize the map 
     map = new Microsoft.Maps.Map(document.getElementById("map"), { credentials: "Au_7giL-8dUbFkJ8zLjcQKy4dV2ftPfpMxQ0_sVBksoj4Y-1nBT00Z1oqUIU894_", 
      mapTypeId: Microsoft.Maps.MapTypeId.road}); 
     Microsoft.Maps.loadModule('Microsoft.Maps.Directions', { callback: directionsModuleLoaded }); 


    } 
     function directionsModuleLoaded() { 
      // Initialize the DirectionsManager 
      directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map); 

      // Create start and end waypoints 
      var startWaypoint = new Microsoft.Maps.Directions.Waypoint({ location: userPosition }); 
      var endWaypoint = new Microsoft.Maps.Directions.Waypoint({ location: latlng }); 

      directionsManager.addWaypoint(startWaypoint); 
      directionsManager.addWaypoint(endWaypoint); 


      // Set request options 
      directionsManager.setRequestOptions({ routeMode: Microsoft.Maps.Directions.RouteMode.driving }); 

      // Set the render options 
      directionsManager.setRenderOptions({ 
       itineraryContainer: document.getElementById('directionPanel'), 
       displayWalkingWarning: false, 
       walkingPolylineOptions: { strokeColor: new Microsoft.Maps.Color(200, 0, 255, 0) }, 
       }); 


      // Specify a handler for when an error occurs 
      Microsoft.Maps.Events.addHandler(directionsManager, 'directionsError', displayError); 

      // Calculate directions, which displays a route on the map 
      directionsManager.calculateDirections(); 



     } 

     function displayError(e) { 
      // Display the error message 
      alert(e.message); 


     } 




     </script> 

답변

0

내 Windows Phone 8 응용 프로그램에서 유사한 문제가 발생합니다. (노키아 920) 웹 사이트 기본 설정이 '데스크톱 버전'으로 설정되어

http://bing.com/maps/default.aspx?cp=47.677797~-122.122013&lvl=12

지도는 제대로를 렌더링합니다.

웹 사이트 환경 설정을 '모바일 버전'으로 설정하면지도가 으로 잘못 표시됩니다 ().

일주일 전부터 일이 시작되었습니다.

1

몇 가지 시도해보십시오. 먼저 앱이 사용자 위치에 액세스 할 수 있는지 확인하십시오. 대부분의 모바일 플랫폼에서는 앱이 매니페스트의 GPS에 액세스해야한다는 표시를해야합니다. 살펴볼 또 다른 사항은 길 안내 관리자의 콜백이 호출되기 전에 userLocation이 채워지지 않을 가능성입니다. GPS가 사용자 위치를 찾기 위해 휴대 기기에서 조금 더 오래 걸릴 수 있으므로 사용자 위치가 설정되기 전에 길 찾기 기능이 실행되기 때문에 null 시작을 전달합니다. 길 찾기 관리자가로드되었음을 나타내는 플래그와 플래그를 설정 한 후에 실행되는 간단한 기능을 사용하는 것이 유용 할 수 있으며 길 찾기 관리자가로드되고 사용자 위치가 모두 사용되고 있는지 확인하는 사용 위치를 설정 한 후에 실행됩니다. 방향을 설정하고 불러 온 기능을 호출합니다.

관련 문제