I have a question / issue with the following scenario:
The application has a track with several hundreds (thousands) of individual points - each containing a lot of additional information -.
So the line is drawn ('com.ptvag.webcomponent.map.vector.Line') and a DynamicTooltip ('com.ptvag.webcomponent.map.vector.DynamicTooltip') is "attached" to it, to get and show the full blown information then.
But here's the problem: When the map is zoomed out, the 'contentProvider' callback functions 'hover event' data 'lineSegment' member does not indicate the "original" segment index, but an index to a shorter "optimized" line.
Is there any way to get the "original" segment index?
Or can I somehow listen only to the "points" of 'vector.Line's?
The following example shows the effect (Paste it into the tutorial "playground"):
At the preset zoom level (18), the optimized line only creates callbacks with lineSegments between 0 and 49.
Once you zoom in, the callback gets correct lineSegments between 0 and 99!
Code: Select all
<html>
<head>
<!--[if IE]><script type="text/javascript" src="webcomponent/script/excanvas.js"></script><![endif]-->
<script type="text/javascript" src="webcomponent/script/qooxdoo/script/qx-transport.js"></script>
<script type="text/javascript" src=".qxrpc"></script>
<script type="text/javascript" src="webcomponent/script/map.js"></script>
<script type="text/javascript">
function init() {
var container = document.getElementById("mapContainer");
var map = new com.ptvag.webcomponent.map.Map(container);
window.onresize = function() {
map.updateSize();
};
map.setCenter({x:4303250, y:5486500});
map.setZoom(18);
var vectorLayer = map.getLayer("vector");
// create 100 segment line
var lineCoords = [];
var x = 4303250,
y = 5486500;
var fX = function (x) { return 200 * x; },
// fY = function (y) { return 200 * y; }; "straight"
fY = function (y) { return 200 * (y%2 ? y : y-1); }; "stair-step"
for (var i = 0; i < 100; ++i) {
lineCoords.push( x+fX(i), y+fY(i) );
}
var line = new com.ptvag.webcomponent.map.vector.Line();
line.setCoordinates(lineCoords);
line.setPixelSize(8);
line.setArrowsOnLine(true);
vectorLayer.addElement(line);
var contentProvider = function (tooltip, data) {
return JSON.stringify({
zoom : map.getZoom(),
lnSeg: data.lineSegment
});
};
var tooltip = new com.ptvag.webcomponent.map.vector.DynamicTooltip();
tooltip.setContentProvider(contentProvider);
tooltip.setAttachedElement(line);
vectorLayer.addElement(tooltip);
}
qxp.dev.log.Logger.ROOT_LOGGER.setMinLevel(qxp.dev.log.Logger.LEVEL_INFO);
qxp.dev.log.Logger.getClassLogger(qxp.core.Init).setMinLevel(qxp.dev.log.Logger.LEVEL_ERROR);
</script>
</head>
<body onload="init()">
<div id="mapContainer"
style="width:100%;height:100%">
</div>
</body>
</html>
Peter