Calculate route in javascript
Posted: Mon Mar 29, 2021 2:53 pm
Within my leaflet map I want to show a route from A to B. But I get the following error:
"Can not deserialize instance of com.ptvag.xserver.xroute.WaypointDesc[] out of START_OBJECT token
at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1@304171af; line: 1, column: 2] (through reference chain: com.ptvag.xserver.xroute.CalculateRouteJsonParams["waypoints"])"
What am I doing wrong?
Below is my declaration of scripts and the script for calculating the route.
"Can not deserialize instance of com.ptvag.xserver.xroute.WaypointDesc[] out of START_OBJECT token
at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1@304171af; line: 1, column: 2] (through reference chain: com.ptvag.xserver.xroute.CalculateRouteJsonParams["waypoints"])"
What am I doing wrong?
Below is my declaration of scripts and the script for calculating the route.
Code: Select all
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
<script type='text/javascript' src='http://localhost:50010/xmap/xmap-client.js'></script>
<script type='text/javascript' src='http://loalhost:50030/xroute/xroute-client.js'></script>
<script type='text/javascript' src='http://loalhost:50020/xlocate/xlocate-client.js'></script>
<script type='text/javascript' src='http://loalhost:50010/leaflet/pages/leaflet/leaflet.js'></script>
<script type='text/javascript' src='http://loalhost:50010/leaflet/leaflet.ptv.js'></script>
<script type='text/javascript' src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-polylinedecorator/1.1.0/leaflet.polylineDecorator.js"></script>
Code: Select all
var A = {
"$type": "OffRoadWaypoint",
"location": {
"offRoadCoordinate": {
"x": 6.1256572,
"y": 49.5983745
}
}
};
var B = {
"$type": "OnRoadWaypoint",
"location": {
"coordinate": {
"x": 6.1256572,
"y": 49.4816576
}
}
};
var xroute = new XRouteClient();
xroute.calculateRoute({ "waypoints": [A, B] }, routed);