2012-04-11 6 views
0

Ovi 매핑을 사용하여 2 개의 다른 연결되지 않은 경로를 표시해야합니다. 그러나 나는 이것을 작동시킬 수 없다. Google지도에서 각 경로에 대한 라우팅 객체를 정의해야했지만 Ovi에서는 작동하지 않습니다. 아무도 아이디어가 있습니까?하나 이상의 Ovi지도에서 2 개 이상의 경로

router = new ovi.mapsapi.routing.Manager(); 

    var onRouteCalculated = function(observedRouter, key, value) 
    { 
     if (value == "finished") 
     { 
      var routes = observedRouter.getRoutes(); 
      var mapRoute = new ovi.mapsapi.routing.component.RouteResultSet(routes[0]).container; 
      map.objects.add(mapRoute); 
      map.zoomTo(mapRoute.getBoundingBox(), false, "default"); 
     } 
     else if(value == "failed") 
     { 
      alert("The routing request failed."); 
     } 
    }; 

    router.addObserver("state", onRouteCalculated); 

    var waypoints = new ovi.mapsapi.routing.WaypointParameterList(); 
    waypoints.addCoordinate(new ovi.mapsapi.geo.Coordinate(x, y)) 
    // coords are ommited, but just a line for every stop point in Lat/Lng format 

    var modes = 
    [{ 
     type: "shortest", 
     transportModes: ["car"], 
     options: "avoidTollroad", 
     trafficMode: "default" 
    }]; 

    router.calculateRoute(waypoints, modes); 

다른 ovi.mapsapi.routing.Manager() 객체를 만드는 또 다른 경로가 작동하지 않습니다에 대한 것을 사용하여 : 참고로

, 여기에 하나 개의 경로에 대한 코드입니다. 이시키는 일이 두 번째 경로 중 하나

이 또한 내가 각 마커에 infobubble를 표시 할 필요가 작동하지 않습니다 처리 기존하지만 난 당신이 노키아를 사용하여 더 나을 것 그들이

답변

0

상주 어떤 용기에 찾을 수 없습니다입니다 Nokia Maps는 Ovi Map API의 2.0 버전이므로 Ovi Maps보다지도.

예에서 A와 B 마커는 "mapRoute"라는 컨테이너에 보관되고, 다른 마커는 "mapRoute"라는 컨테이너에 보관됩니다. 별도의 라우트는 routesArr []

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html> 
<head> 
     <script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/2.2.0/jsl.js?routing=auto"></script> 
    <title>Concurrent Routing example</title> 
</head> 
<body> 

<div id="mapContainer" style="top:30%; width:100%; height:70%; position: absolute;"></div> 

<script type="text/javascript"> 
///////////////////////////////////////////////////////////////////////////////////// 
// Don't forget to set your API credentials 
// 
// Replace with your appId and token which you can obtain when you 
// register on http://api.developer.nokia.com/ 
// 
      nokia.Settings.set("appId", "YOUR APP ID GOES HERE"); 
      nokia.Settings.set("authenticationToken", "YOUR AUTHENTICATION TOKEN GOES HERE"); 

//   
///////////////////////////////////////////////////////////////////////////////////// 


//initialize a new map 
var display = new nokia.maps.map.Display(document.getElementById("mapContainer"), 
        {  "components": [ 
            new nokia.maps.map.component.ZoomBar(),     
            new nokia.maps.map.component.Behavior(),     
            new nokia.maps.map.component.TypeSelector()],  
            "zoomLevel": 13, 
            "center" : [52.500556, 13.398889] }); 


var onAllManagersFinished = function() {  
    for (i = 0; i <routesArr.length; i++){ 

      console.log(routesArr[i]); 

     var mapRoute = new nokia.maps.routing.component.RouteResultSet(routesArr[i]).container; 
     display.objects.add(mapRoute); 
     display.zoomTo(mapRoute.getBoundingBox(), true); 
     } 
}; 

// we will use the same state observer function for all managers  

var onRouteCalculated = function (observedRouter, key, value) { 
    if (value == "finished") { 
     routesArr[observedRouter.$index] = observedRouter.getRoutes()[0]; 
     managersFinished++; 
    } else if (value == "failed") { 
     // Something has gone horribly wrong e.g. route too long. 
     alert("The routing request failed."); 
     managersFinished++; 
    } 


    if(managersFinished === waypointsArr.length) { 
      onAllManagersFinished(); 
     } 

};     



var routesArr = new Array(); 
var waypointsArr = new Array(); 
var MunichBerlin = new nokia.maps.routing.WaypointParameterList(); 
MunichBerlin.addCoordinate (new nokia.maps.geo.Coordinate(48.133333, 11.566667)); 
MunichBerlin.addCoordinate (new nokia.maps.geo.Coordinate(52.500556, 13.398889)); 

var BerlinHamburg = new nokia.maps.routing.WaypointParameterList(); 
BerlinHamburg.addCoordinate(new nokia.maps.geo.Coordinate(52.500556, 13.398889)); 
BerlinHamburg.addCoordinate(new nokia.maps.geo.Coordinate(53.565278, 10.001389)); 

waypointsArr.push(MunichBerlin); 
waypointsArr.push(BerlinHamburg); 



var i = waypointsArr.length; 
var managersFinished = 0; 

// iterate over all route requests, create a manager for each of them, 
// add the observer and call the claculateRoute method 

while(i--) {  
    var router = new nokia.maps.routing.Manager(); 
    router.$index = i; 
    router.calculateRoute(waypointsArr[i], [{ 
          type: "shortest", 
          transportModes: ["car"], 
          options: "", 
          trafficMode: "default" 
          }]); 
    router.addObserver("state", onRouteCalculated); 
} 

</script> 
</body> 
</html> 
관련 문제