Developer's Guide > Programming Environment > Using PTV xServer with JavaScript

Using PTV xServer with JavaScript

Test and discover PTV xServer in a live environment with our Code Sample Browser. Please note that only the PTV xServer bundle includes the Code Sample Browser, but each PTV xServer includes their respective JavaScript Clients (e.g. the JavaScript xMap client is located in the directory <root path>/webapps/xmap). All mandatory libraries and third-party components are automatically supplied in the webapps folder.

Caution: As there are several map widgets and versions available, we cannot support all of them. To use PTV xServer with up to date map widgets, we recommend the WMS adapter and xserverjs. It supports Leaflet versions 0.7 to 1.4 and OpenLayers versions 2 and 3 and can be used both on premise and with xServer Internet.
The sample below uses the outdated Leaflet version 0.7.

Description: This sample illustrates the minimum code necessary to use the Leaflet map widget. Just with a few lines you are able to create a flexible map that adapts to change browser window sizes. The example map contains only small parts of the world: Luxembourg and Rhode Island. PTV offers a wide range of different maps for a lot of regions in the world.

The external JavaScript files for Leaflet and the convenient xMap client are added as script elements with the obligatory type and the source linked to each JavaScript.

<!-- Leaflet -->
<script type="text/javascript" src="/xmap/xmap-client.min.js"></script>
<script type="text/javascript" src="/leaflet/pages/leaflet/leaflet.js"></script>
<script type="text/javascript" src="/leaflet/leaflet.ptv.js"></script>

Output