Go to Google Groups Home    Google Maps API
Re: text API

Mike Williams <nos...@econym.demon.co.uk>

If you really don't want to convert your text into XML, then I suggest
you start like this:

Grab the XML example code from my tutorial

   http://www.econym.demon.co.uk/googlemaps/basic3.htm

Then make the following changes to the XML processing bit to convert it
to text processing:

* use request.responseText instead of request.responseXML

* rip out all the getElementsBtTagName and getAttribue stuff and replace
it with the string.split() method:

    var gpsDoc = request.responseText;

    // Split it on 'newline' into an array of lines
    var markers = gpsDoc.split('\n');

    // Loop through the lines
    for (var i = 0; i < markers.length; i++) {

        // If empty don't process
        if (!markers[i]){break}

        // Split each line on ':' into an array of parts
        var part = markers[i].split(':');

        // Grab the parts
        var date = part[0];
        var name = part[1];
        var lng = parseFloat(part[2]);
        var lat = parseFloat(part[3]);

        var marker =  new GMarker(new GPoint(lng,lat));
        map.addOverlay(marker);
    }