Javascript Nokia Here在构建具有多个坐标的路线时映射错误

Javascript Nokia Here在构建具有多个坐标的路线时映射错误,javascript,polyline,here-api,Javascript,Polyline,Here Api,例如,我有500个路线坐标,我希望构建路线使用从点A到点B的坐标 现在我使用了以下代码: router = new nokia.maps.routing.Manager(); // The function onRouteCalculated will be called when a route was calculated var onRouteCalculated = function (observedRouter, key, value) {

例如,我有500个路线坐标,我希望构建路线使用从点A到点B的坐标

现在我使用了以下代码:

router = new nokia.maps.routing.Manager();

    // The function onRouteCalculated  will be called when a route was calculated
        var onRouteCalculated = function (observedRouter, key, value) {
            if (value == "finished") {
                var routes = observedRouter.getRoutes(),
                    container = new nokia.maps.map.Container(),
                    route = routes[0],
                    waypoints = route.waypoints,
                    i, length = waypoints.length;

                // Add route polyline to the container
                container.objects.add(new nokia.maps.map.Polyline(route.shape, {
                    pen : new nokia.maps.util.Pen({
                        lineWidth: 5,
                        strokeColor: "#AB7A8C"
                    })
                }));

                // Add container to the map
                map.objects.add(container);

                // Iterate through all waypoints and add them to the container
                for (i = 0; i < length; i++) {
                    //
                    container.objects.add(new nokia.maps.map.StandardMarker(waypoints[i].originalPosition, {
                        text: String.fromCharCode(65 + i) //65 is a char code for "A"
                    }));
                }
                //Zoom to the bounding box of the route
                map.zoomTo(container.getBoundingBox(), false, "default");
            } else if (value == "failed") {
                alert("The routing request failed.");
            }
        };

        /* We create on observer on router's "state" property so the above created
         * onRouteCalculated we be called once the route is calculated
         */
        router.addObserver("state", onRouteCalculated);

    // Create waypoints
        var waypoints = new nokia.maps.routing.WaypointParameterList();

        $.each(routesArr, function (key, value){
nokia.maps.geo.Coordinate(parseFloat(value[1]), parseFloat(value[0])));
                var Coords = value.split(' ');
                console.log(Coords);
                waypoints.addCoordinate(new nokia.maps.geo.Coordinate(parseFloat(Coords[1]), parseFloat(Coords[0])));
        })

        console.log(waypoints);

        /* Properties such as type, transportModes, options, trafficMode can be
         * specified as second parameter in performing the routing request.
         *
         * See for the mode options the "nokia.maps.routing.Mode" section in the developer's guide
         */
        var modes = [{
            type: "fastest",
            transportModes: ["car"],
            trafficMode: "disabled",
            options: ""
        }];

    // Trigger route calculation after the map emmits the "displayready" event
        map.addListener("displayready", function () {
            router.calculateRoute(waypoints, modes);
        }, false);

我解决不了这个问题,有人会遇到这个问题吗?

如果你只是在地图上画一条线,不想要一条
路线,你想要一条:

e、 g

目前,您的样本正在尝试计算从A到B到C到D的驾驶指令。。。。到第500点,我怀疑这是你想要的。你可以定义的中间点的数量是有限的,如果我记得的话,大约是10个

您可以使用以下方法
zoomTo
缩放路线:

map.zoomTo(polyline.getBoundingBox(), false, "default");

是的,它对我有用。但我如何在这条多段线路线上设置中心呢?是的,这对我很有用。1.但是如何在多段线路线上设置中心?2.问题[link]只需使用
map.setCenter()
多段线。getBoundingBox().getCenter()
zoomTo()
,如上面的答案所述。使用zoomTop完成。当我更新zoomTom problem live时,我使用了地图版本2.5.3。谢谢你的帮助
// Set of initial geo coordinates to create the purple polyline
var points = [
  new nokia.maps.geo.Coordinate(50.1299, 8.5680),
  new nokia.maps.geo.Coordinate(50.0969, 8.4829),
  new nokia.maps.geo.Coordinate(50.0819, 8.4856),
  new nokia.maps.geo.Coordinate(50.0555, 8.4479)
];

// Transparent purple polyline
var polyline = new nokia.maps.map.Polyline(
  points,
  { 
    pen: {
      strokeColor: "#22CA", 
      lineWidth: 5
    }
  }
);

 map.objects.add(polyline);
map.zoomTo(polyline.getBoundingBox(), false, "default");