Page 1 of 1

Calculate route in javascript

Posted: Mon Mar 29, 2021 2:53 pm
by broadhorizon
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.

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);

Re: Calculate route in javascript

Posted: Tue Mar 30, 2021 6:50 am
by Joost
Your code is a call for xRoute 2 but the you are using xRoute 1. XServer 2 has a different API 1 then xServer 1.

For some xServer 1 javascript example i would recommend to check the xServer 1 code same browser: https://svc-eu-h-test.cloud.ptvgroup.co ... pleBrowser . It has been written in Javascript and for each sample you can use the edit button in the top right to have a look at the source code.

Direct link to a routing sample source code:
https://svc-eu-h-test.cloud.ptvgroup.co ... imple/edit

Re: Calculate route in javascript

Posted: Tue Mar 30, 2021 6:55 am
by broadhorizon
Joost wrote:Your code is a call for xRoute 2 but the you are using xRoute 1. XServer 2 has a different API 1 then xServer 1.

For some xServer 1 javascript example i would recommend to check the xServer 1 code same browser: https://svc-eu-h-test.cloud.ptvgroup.co ... pleBrowser . It has been written in Javascript and for each sample you can use the edit button in the top right to have a look at the source code.

Direct link to a routing sample source code:
https://svc-eu-h-test.cloud.ptvgroup.co ... imple/edit
Dank je wel Joost.

Ik ga ermee aan de slag.

groet Lanzo