POI#tooltipContent & DynamicTooltip mutual exclusive?

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.

POI#tooltipContent & DynamicTooltip mutual exclusive?

Postby tisptv » Thu Oct 29, 2015 2:56 pm

Hello,

I'm having problems with Tooltips on the AJAX xMaps:
Here's the scenario:

1. I add some POI elements[1] and set their tooltipContent property
All POIs are shown and their tooltips show up, too. Nice -so far-

2. I add a Line element[2] and attach a DynamicTooltip element[3] via "DynamicTooltip#setAttachedElement" to it.
Now, the tooltip is shown for the line, but not for any of the POIs added at (1)!
Furthermore, even if the line is removed, the POIs will not show any tooltip!

I have no idea what might be the reason for this or how to work around this problem.

/Regards,
Peter

---------------------
[1] com.ptvag.webcomponent.map.vector.POI
[2] com.ptvag.webcomponent.map.vector.Line
[3] com.ptvag.webcomponent.map.vector.DynamicTooltip
tisptv
 
Posts: 9
Joined: Thu Sep 03, 2015 8:32 am

Re: POI#tooltipContent & DynamicTooltip mutual exclusive?

Postby tisptv » Thu Oct 29, 2015 5:02 pm

I was able to remove the problem (I hope) with the following procedure:
When removing the Line from the Layer, I also "detach" the DynamicTooltip and the Line from each other.
That seems to resolve the issue.

So something in the lines of:
javascript code
var lineId;    // 'private' class members
var tooltipId; // " "
// ----------------------------------------------
function addLine ()
{
var vectorNS = com.ptvag.webcomponent.map.vector; // namespace shortcut

var vectorLayer = map.getLayer("vector"); // map beeing instanceof com.ptvag.webcomponent.map.Map

var line = new vectorNS.Line();
line.setPixelSize(8);
// ...
line.setCoordinates(lineCoords);

lineId = vectorLayer.addElement(line);

var tooltip = new vectorNS.DynamicTooltip();
tooltip.setAttachedElement(line);
tooltip.setContentProvider(...);
tooltipId = vectorLayer.addElement(tooltip);
};

// ----------------------------------------------
function removeLine ()
{
var vectorLayer = map.getLayer("vector");

// 'detach' line <-> Tooltip connection!
var tooltip = vectorLayer.getElement(tooltipId);
tooltip.setAttachedElement(null);

vectorLayer.removeElement(tooltipId);
vectorLayer.removeElement(lineId);
};

Note: this code is "cut'n'paste", so might not contain all necessary parts.
/Peter
tisptv
 
Posts: 9
Joined: Thu Sep 03, 2015 8:32 am

Re: POI#tooltipContent & DynamicTooltip mutual exclusive?

Postby Bernd Welter » Wed Nov 04, 2015 4:00 pm

Hello Mr Schneider,

one of our developers took a look at this part of the code and he wasn't able to recognize the solution in this visible code. He assumes that you resolved it somewhere else.

We will therefore not be able to investigate this :roll: ;-)

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


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