Why commonkml ?
This project was developed from my coding of a
KML website using the PHP language. I wanted a way to improve my webpages with
the following needs:
* re-use code where possible for common routines
* simplify the code so it was shorter and more readable
* reduce errors made in coding
* extend the KML with new features made from existing ones
* improve debugging
* Provide International Language support
After coding various dynamic KML pages including a game, I devised a library of
routines that I could include into any webpage. Here is the worst part of it:
* Extra level of coding to learn
* hides the real KML code
* needs to load an external library to work
* attribute names are not obvious
That last listed trade off I have made is that the purpose of attributes in a
tag is nolonger obvious as the attribute name is not shown. Consider:
<TEXT coords='10,20' font='0' pen='65'>hello</TEXT>
It is clear that 65 belongs to pen, and the 0 is a font attribute.
This becomes:
text(10,20,0,65,'hello');
This is shorter, but it is not obvious that the 3rd paramter is for the font,
and 4th is pen. I found out nothing shows up when I have a font of 65, and the
colour is 0 (transparent).
The answer is to use meaingful contants:
text(10,20,FONT0,RED,'hello');
So with this format there is a great benefit of using the library. You do not
have to keep swapping between KML and PHP so much, and my colour coded editor
displays the PHP much better than the KML (unless I define all the syntax of KML).
Debugging
I built a feature into the library that will make the KML visible when viewed on
a normal computer browser such as Netscape or IE. The trick was to make the
output text/plain. However to overcome a bug in IE, I also have to hide the
<?xml /> tag. The code will work as normal on a Kiss player and in a KML browser
program, as these both have the URL parameter of PlayerBrand.
If you need to review the contents of the commonkml.php that is on your web
browser, then just put the url to it in your PC browser.
Future
The current function list does not cover all the existing KML functions. For
example, there is no support for the background gradients. I shall extend these
as I find time or the need arises.
Some future inclusions may be:
* Placement of background images (align left, right, sizing etc)
* Word wrap (done, but more options)
* Multiple pages of text
* Text formating and flow around images
* Handle the new KML version 2
* Simple menu generation
* grouping of functions, then call the group like a new function call.
* Get label of bottom left key (either Clear or Del depending on model)
* Convert http://somewhere.com to http://somewhere.com/ in abs_url().
* Filled rectangle or rectangle around some text. Good for menu highlight.