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:

TruckAttributesConf.zip
(6.71 KiB) Downloaded 279 times


You can query the truck attributes overlay with a WMS request then:

http://80.146.239.180/WMS/WMS?LAYERS=xmap-truckattributes&FORMAT=image%2Fpng&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG:900913&BBOX=677303.702511,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-name>cors.supportedHeaders</param-name>
      <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: 97
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
xmap.maps=*
xmap.base=true
xmap.layers.poi=true
xmap.layers.trafficInfo=true
xmap.layers.RoadEditor=true
xmap.layers.rasterLayer=true


Best regards, Birk
daxbin
 
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

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

Re: Display TruckAttributes with Leaflet and OpenLayers

Postby sebastian.pietrzak » Tue Apr 03, 2018 10:43 pm

Hello everyone,

im trying to run TruckAttributes on my xServer but i dont fully understand this description

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:

TruckAttributesConf.zip
download/file.php?id=111

I just downloaded archive file with : truckattributes.ini, wms.properties and xmap-truckattributes.properties.

i have compared file xmap-truckattributes.properties from downloaded archive file with file which i have since installation xmap 1.24.0.1. I dont see any differences. This same is with file wms.properties and last file truckattributes.ini.

I trying run program https://github.com/ptv-logistics/Leaflet.PtvLayer with my server setup. But after when map show up i see only street without name and plus/minus. I dont see Tool-tip and any additional layer like TruckAttributes.

Its strange beacuse when i switch to your server all works fine. Where is problem ??
User avatar
sebastian.pietrzak
 
Posts: 6
Joined: Fri Apr 07, 2017 12:28 pm
Location: Poznań, Poland

Re: Display TruckAttributes with Leaflet and OpenLayers

Postby Bernd Welter » Wed Apr 04, 2018 12:46 pm

Hello Sebastian,

I delegated the topic to two colleagues (LNM, OH). OH is on vacation, LNM will take care of it. Maybe there is no 100% satisfying solution without a change of the used interface or framework. We'll see.

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

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

Re: Display TruckAttributes with Leaflet and OpenLayers

Postby Bernd Welter » Thu Apr 05, 2018 6:53 am

Hello Sebastian,

here's Oliver's response to your question. Does this answer it?
https://github.com/ptv-logistics/Leafle ... r/issues/1

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

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

Re: Display TruckAttributes with Leaflet and OpenLayers

Postby Bernd Welter » Thu Apr 05, 2018 6:53 am

Hello Sebastian,

here's Oliver's GITHUB response to your question. Does this answer it?

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

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

Re: Display TruckAttributes with Leaflet and OpenLayers

Postby Oliver Heilig » Thu Apr 05, 2018 9:50 am

Hello Sebastian,

please read this:

viewtopic.php?f=15&t=834

Regards

Oli
Oliver Heilig
Chief Developer
PTV GROUP - Germany

https://github.com/oliverheilig/
User avatar
Oliver Heilig
 
Posts: 97
Joined: Tue May 13, 2014 12:10 pm
Location: Karlsruhe, Germany

Re: Display TruckAttributes with Leaflet and OpenLayers

Postby sebastian.pietrzak » Thu Apr 05, 2018 8:33 pm

Thank you for the quick reply.

I downloaded latest repo from github.Next i copied files from folder xmap-conf to my xMap Server/conf/
( i replaced all ).After all i rebooted service PTV xMap Server 1.24.0.1.
Without any change i opened index.file in Safari, Firefox, IE and Chrome with --allow-file-access-from-files.
Result is this same. I used your server.
Image

I thought maybe there was problem with no token(line throw "NO TOKEN"; saw).
No problem i switched to my xMap server

In code changed :

var xMapUrl = 'https://xmap-' + cluster + '.cloud.ptvgroup.com';
to
var xMapUrl = 'https://myOwnxMap'; ( correct address i will send to Bernd, beacuse i know his email ).

comment line throw "NO TOKEN";

I see Tool-tip with checked additional layers. But i dont see any on the map.
Image


Next i Checked lines with function getXMapBaseLayers and changed code line 126

var background = L.tileLayer('https://ajaxbg{s}-' + cluster + '.cloud.ptvgroup.com/WMS/GetTile/' +
to
var background = L.tileLayer('http://myOwnxMap/WMS/GetTile/' +

Now i have only problem with line 133. There is used token to xServer Internet. On my own installation i dont have token.

var foreground = new L.NonTiledLayer.WMS('https://ajaxfg-' + cluster + '.cloud.ptvgroup.com/WMS/WMS?xtok=' + token,
to
var foreground = new L.NonTiledLayer.WMS('http://myOwnXMap/WMS/WMS,

Result is better. I see street labels but TruckAttributes as i have not seen, i dont see further.
Image
User avatar
sebastian.pietrzak
 
Posts: 6
Joined: Fri Apr 07, 2017 12:28 pm
Location: Poznań, Poland

Re: Display TruckAttributes with Leaflet and OpenLayers

Postby Oliver Heilig » Fri Apr 06, 2018 12:40 pm

In the index.html set e.g.

Code: Select all
        var xMapUrl = 'http://127.0.0.1:50010';


The samples should work with http://127.0.0.1:50010 and xtok = '''. I must admit i havent tested it for on-premise. A customer reported a similar issue for a sample i've fixed. https://github.com/ptv-logistics/xserve ... /xserver-1

What's important is that the Autorization Header is not set for on-premise. Theres a check, if the token is empty https://github.com/ptv-logistics/Leafle ... er.js#L197 To make sure you can just remove the line.

If it still doesn't work it should be a CORS configuration problem of your xServer. You should see an error in the console (F12 - something with cross origin). Maybe your xServer is not configured for CORS. It's in some file in the xServer Tomcat configuration. I cannot get my hand on an xServer installation now, so you have to wait till next week.

Oli
Oliver Heilig
Chief Developer
PTV GROUP - Germany

https://github.com/oliverheilig/
User avatar
Oliver Heilig
 
Posts: 97
Joined: Tue May 13, 2014 12:10 pm
Location: Karlsruhe, Germany

Next

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

cron