nokia.maps.routing.WaypointParameterList is not a function
Hi,
I am workin me into the api.
following problem:
[CODE]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/2.2.0/jsl.js?with=all"></script>
<script type="text/javascript" charset="UTF-8" src="jquery.js"></script>
<title>lala</title>
</head>
<body>
<script type="text/javascript">
/* Set authentication token and appid
* WARNING: this is a demo-only key
* please register on http://api.developer.nokia.com/
* and obtain your own developer's API key
*/
nokia.Settings.set( "appId", "_peU-uCkp-j8ovkzFGNU");
nokia.Settings.set( "authenticationToken", "gBoUkAMoxoqIWfxWA5DuMQ");
var router = new nokia.maps.routing.Manager(); // create a route 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();
alert('OK');
} 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();
waypoints.addCoordinate(new nokia.maps.geo.Coordinate(52.51652540955727, 13.380154923889933));
waypoints.addCoordinate(new nokia.maps.geo.Coordinate(52.52114106145058, 13.40921934080231));
/* 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: "shortest",
transportModes: ["car"],
options: "avoidTollroad",
trafficMode: "default"
}];
// Calculate the route (and call onRouteCalculated afterwards)
router.calculateRoute(waypoints, modes);
</script>
</body>
</html>[/CODE]
Throws "nokia.maps.routing.WaypointParameterList is not a function" exception....
Whats my fault ?
Re: nokia.maps.routing.WaypointParameterList is not a function
I've tried your code in a variety of browsers (Google Chrome 18, Safari 5.1.2, IE 8.0, FF 11.0) and it seems to work for me. The only thing that is potentially missing is a quirks mode meta statement:
[CODE]<meta http-equiv="X-UA-Compatible" content="IE=7; IE=EmulateIE9" />[/CODE]
What browser are you using? I'm guessing you may have a JavaScript problem with an obsolete browser somehow.
The only suggestion I have is to look at the following pair of examples (which basically duplicate your use case) to see how it has been done elsewhere:
[url]http://api.maps.nokia.com/en/playground/examples/maps/services/routing.html[/url]
[url]http://www.developer.nokia.com/Community/Wiki/Nokia_Maps_API_-_How_to_calculate_a_route_between_two_points[/url]
Do they work for you?
Re: nokia.maps.routing.WaypointParameterList is not a function
Just for further information, you [B]will[/B] get a "nokia.maps.routing.WaypointParameterList is not a [B]constructor[/B]" message if you attempt to use routing without having loaded the routing library of the API. The cause of this is a missing parameter when loading the API:
i.e.
[CODE]<script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/2.2.0/jsl.js"></script>[/CODE]
Should be:
[CODE]<script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/2.2.0/jsl.js?routing=auto"></script> [/CODE]