Updated JSON API

[Edit: 30.10.2012: Check the post PTV xServer Web App Demo A-to-B Routing – a demonstration of the benefits of JSON with a concrete example]

We’ve updated the Code Sample Browser with a preview of the PTV xServers 1.16. Therefore the JSON API has slightly been changed. Here’s a brief update on the information we provided in the blog article of July 2012.

The PTV xServer add-on AJAX Maps API did not change. The information we provided is still up to date. What has changed are the scripts, constructors and method calls for xRoute and xLocate. To include xRoute and xLocate in your HTML-page, these lines must be provided:

<!--xRoute JSON -->
<script type="text/javascript" src="/xroute/xroute-client.js">
</script>
<!--xLocate JSON -->
<script type="text/javascript" src="/xlocate/xlocate-client.js">
</script>

The constructor calls now look like this:

var xroute = new XRouteClient();
var xlocate = new XLocateClient();

The method signatures also changed a little bit. Asynchronous calls do not need the ‘Async’ suffix anymore. We just moved the callback handler to the last position in the method call and made it optional. So if a callback handler is provided the method will be executed in asynchronous mode. Here is an example for this:

xroute.calculateRoute(waypoints, null, null, rlo, cc, 
routeCalculated);

We highly recommend to use the asynchronous mode only.

 

That’s all! Give it a try in the Code Sample Browser!

 

This entry was posted in PTV xServer and tagged , , by Martina Beck. Bookmark the permalink.

About Martina Beck

Martina Beck has been working for PTV since 2000. As certified computer scientist she was originally responsible for providing customers with technical support and she later moved on to the Product Management division. Since 2011 she has been working for PTV as an online marketing manager in international marketing with an emphasis on social media (et al. Facebook, Twitter, Google+, YouTube). The PTV Developer Blog is the PTV Developer Components' lead channel. The posts on important topics and trends originate from close cooperation with developers, the product management and other experts.