Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

XML returns invalid data for Mapview

Hi!

Im using a xml-file to get lat+long to put on a map. It works fine when reading the file from my computer, but when I try to read the same content via internet it fails. I get the values, but they dont appear on the map.

I have tried parseFloat the values, but with no luck.

var data = [];

var xhr = Ti.Network.createHTTPClient();
xhr.open("GET","http://example.com/jobbs.xml");
xhr.onload = function()
{

    var doc = this.responseXML.documentElement;

    try
    {
        var x = doc.getElementsByTagName("job");


        for(var i = 0; i < x.length ; i++){    

            var lat = x.item(i).getElementsByTagName("latitude").item(0).text;
            var lon = x.item(i).getElementsByTagName("longitude").item(0).text;

            data[i] = Titanium.Map.createAnnotation({
                latitude:parseFloat(lat),
                longitude:parseFloat(lon)
            });
        }

    }
    catch(E)
    {
        alert(E);
    }

};
xhr.send();

var mapview = Titanium.Map.createView({
    ...
    annotations: data
});

win.add(mapview);
— asked November 5th 2010 by Johnny Nilsson
  • createannotation
  • iphone
  • mapview
  • mobile
  • xhr
  • xml
1 Comment
  • what does the data file look like? Problem in probably there

    — commented November 5th 2010 by Aaron Saunders

0 Answers

The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.