정말 내 문제가 도움이되기를 바랍니다. 모바일 앱인 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>