Display TruckAttributes with Leaflet and OpenLayers

This forum deals with any kind of web based client technology, whether it is the well known java script based Ajax servlet or the upcoming approaches such as Leaflet, OpenLayers and so on.

Display TruckAttributes with Leaflet and OpenLayers

Postby Oliver Heilig » Fri Feb 06, 2015 3:45 pm

Hi there,

here's short tutorial of how to add TruckAttributes layer to Leaflet and OpenLayers

Method 1: TruckAttributes via WMS

Demo OpenLayers: http://jsfiddle.net/oliverheilig/ea2kwcmf/
Demo Leaflet: http://ptv-logistics.github.io/Leaflet.NonTiledLayer/

The technique behind this approach is to add a new WMS Layer for TruckAttributes, so the layer can be switched ON/OFF independently. To achieve this, we have to add a new rendering profile to the xMap conf-directory and extend the WMS.properties file by a xmap-truckattributes layer. Here are the required files:

(6.71 KiB) Downloaded 263 times

You can query the truck attributes overlay with a WMS request then:,6376172.98006,687651.36561,6382321.383758&WIDTH=1083&HEIGHT=643

xServer internet has these extensions already included, so you can also use this approach with xServer internet. Note: for "single-tile" WMS, Leaflet requires an addon we provide on GitHub: https://github.com/ptv-logistics/Leaflet.NonTiledLayer

Method 2: TruckAttributes via xMap/renderMap directly

The WMS response only contains an image, so you cannot implement some tooltip-interaction. We have a sample for adding TruckAttributes with tooltip information in Leaflet.

Demo Leaflet: http://ptv-logistics.github.io/Leaflet.PtvLayer/?layers=ta

Here the xServer is requested directly and the response contains the image plus object information. The object information is used to create clickable regions on the client. You can also apply this to your on-premise xServer installation, if you copy the attached rendering profiles.

Important: If you want to use the PTVLayer js-code with your xMapServer directly, you to have configure CORS at your .\webapps\xmap\WEB-INF\web.xml file and add the authorization and accept header:
Code: Select all
      <param-value>Content-Type, origin, X-Requested-With, username, password, features, authorization, accept</param-value>

You can use this approach also with xServer internet, as it supports CORS for all xServers.
User avatar
Oliver Heilig
Posts: 88
Joined: Tue May 13, 2014 12:10 pm
Location: Karlsruhe, Germany

Which license is required for displaying TruckAttributes via

Postby daxbin » Tue Apr 04, 2017 2:28 pm

Hello Oliver,

I just tried to display TruckAttributes with OpenLayers via WMS (by the way, switching different styles classic, gravelpit, sandbox, silkysand as background maps and switching on/off labels as overlay layers works fine).

But when switching on the TruckAttributes layer there is nothing to see as if everything were transparent in this layer.

So I took a look into the logs and in the WMS.log I found there
Code: Select all
2017-04-04 15:53:58,481;ERROR;com.ptvag.wms.layer.http.HttpComponentsBasedClient;http-bio-50010-exec-18;WMS ERROR: 500, Internal Server Error
2017-04-04 15:53:58,482;ERROR;com.ptvag.wms.layer.http.HttpComponentsBasedClient;http-bio-50010-exec-18;Unable to render map, RoadEditorLayer is not licensed. Please contact your vendor for a proper license.

What kind of license is missing to me because the xmap section of my license.ptv looks like this
Code: Select all

Best regards, Birk
Posts: 13
Joined: Thu Feb 16, 2017 2:03 pm

Re: Display TruckAttributes with Leaflet and OpenLayers

Postby Bernd Welter » Tue Apr 04, 2017 2:34 pm

Hello Birk,

sounds like a xMap issue. Please capture the native malicious request of xMap and provide it to us here: viewforum.php?f=5

With the rough info I can't answer your question.

Best regards Bernd
Bernd Welter
Manager Technical Consulting & Requirement Engineering
Senior Technical Consultant Developer Components
PTV GROUP - Germany

User avatar
Bernd Welter
Site Admin
Posts: 937
Joined: Mon Apr 14, 2014 10:28 am

Return to PTV Webclients (Ajax, Leaflet, OpenLayers, WMS, ...) (Admin=LNM)