[ka-Map-users] kaxmloverlay issues and workarounds

Mark Wright sparkymeister at gmail.com
Sun Apr 23 21:37:45 EDT 2006

I noticed an issue when drawing a linestring with kaxmloverlay where
it would not connect the last two points in the line. The workaround I
am using is to repeat the last point. I'm wondering if this is a known
bug or if there's something wrong with my xml, which I copied below:

<point id="line1" x="-698" y="4165" redraw="true">
<linestring stroke="3" opacity="1.0" color="#cc0000">-698 4165, 1193
3613, 2787 3530, 3467 2819, 2787 2146, 1155 2152, 558 2730, -831 3784,
-933 4095, -1454 4356, -1454 4356</linestring>

As you can see this includes my workaround where the last coordinate
is repeated.

I have also run into a problem where I have lines that are too long to
be passed to the drawgeom.php script. Basically, it's longer than the
querystring can handle. My workaround here has been to make the script
I use to generate the above xml also create the same linestring that
is sent to the drawgeom.php script and store it inside
$_SESSION['kaLine']. I basically translated the
kaXmlFeature.prototype.readCoordinates javascript function into a php
function. This function assumes the line is already broken into an
array of "x y" coordinates and the first thing it does is to repeat
the last coordinate so that the last line segment will be drawn.

function makeKaXMLline($line,$scale)
	$line[] = $line[count($line) - 1];

 	$pp = $line;
	$cxmin = 0;
	$cymax = 0;
	for ($i=0; $i<count($pp); $i++) {
		$s = $pp[$i];
		$xy = explode(' ',$s);
		if ($xy != null) {
			$cx[] = $x;
			$cy[] = $y;
			if ($i==0 || $x<$cxmin) $cxmin = $x;
			if ($i==0 || $y>$cymax) $cymax = $y;
	// Normalize the coordinates
	for ($i=0; $i<count($pp); $i++) {
		$x = round(($cx[$i] - $cxmin) / $scale);
		$y = round(($cymax - $cy[$i]) / $scale);
		if ($i>0) $coords .= ",";
			$coords .= "$x,$y";
	return $coords;

Then in the drawgeom.php script I start a session and after all the
variables are set from the querystring (around line 90) I add

$coords = ($type == 'L' && $_SESSION['kaLine'])?$_SESSION['kaLine']:$coords;

Now I can have as many points in my line as I want. However, none of
this would be necessary if the line was sent to drawgeom.php as POST
rather than GET. Is this possible?


Have fun or die trying - but try not to actually die.

More information about the ka-Map-users mailing list