Here is a fast and dirty svg file that demonstrates the use of XML
with gpsfeed+. The javascript functions use getURL and parseXML to
obtain and parse the XML gps data, which is then drawn on the canvas.
The XML snippet that goes into the relevant gpsfeed+ textbox is:

<?xml version="1.0"?>
<pt x="$lon" y="$lat"/>

The svg file is:

<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
        "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd";>
<svg id="svg"  xmlns="http://www.w3.org/2000/svg";
xmlns:xlink="http://www.w3.org/1999/xlink"; onload="init(evt)"
viewBox="23.5 37.5 1 1" xml:space="preserve">
<script type="text/ecmascript"><![CDATA[
count=0;
function init (evt) {
        svgdoc=evt.target.ownerDocument;
        svgroot=svgdoc.rootElement;
        loadFile();
}
function loadFile () {
        getURL("gpsfeed?type=xml", fileLoaded);
}
function fileLoaded (data) {
        var msg = '';
        if(data.success) {
                var frag = parseXML(data.content,svgdoc);
                var lon = frag.firstChild.getAttribute("x");
                var lat = frag.firstChild.getAttribute("y");
                var line=svgdoc.getElementById("line")
                var d=line.getAttribute("d")
                if(count>1000) {
                        d="M24 38";
                        count=0;
                } else {
                        d=d+' '+lon+' '+lat;
                        count=count+1;
                }
                var fix=svgdoc.getElementById("fix");
                fix.setAttribute("cx",lon);
                fix.setAttribute("cy",lat);
                line.setAttribute("d",d);
                setTimeout("loadFile()", 1000)
        } else {
                msg = 'Loading has failed';
                alert(msg);
        }
}
]]></script>
<path id="line" style="fill:none;stroke:black;stroke-width:0.001;"
d="M24 38" />
<circle id="fix" r="0.01" style="fill:red; stroke:black; stroke-width:
0.001"/>
</svg>

Dimitrios





-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to