PDA

View Full Version : XMLreader - Google map info



mkariti
2 Sep 2011, 6:13 AM
Hi there,
Ive got this following code:


var store = new Ext.data.Store({
model: 'Sun',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'http://localhost:1280/MobileTouchApp/GetXMLParams.ashx',
reader: {
type: 'xml',
model: 'Sun',
root: 'sun',
record: 'sun'
}
}


and Im trying to get the "sunset" value from the XML file doing the following:
var getSunsetTime = store.data.items[0].data.sunset;
But I cant seems to get it right.
in firebug this: store.data.items[0].data.sunset will return the sunset hour.
Does anyone know how to extract the xml information in order to print it on the screen?
many thanks
mkariti

mkariti
2 Sep 2011, 2:09 PM
I guess because its Ajax the store was loading the data too late. so ive added a call back function to the store.load() function which seems to work fine.
However, How can I wait for the data to arrive before executing the progarmme???


store.load({
callback: function (records, operation) {
alert("Sunset time: " + store.data.items[0].data.sunset +" TimeZone "+ store.data.items[0].data.timezone);
}
});

Cheers

mkariti
2 Sep 2011, 2:14 PM
Ok Solved it!
Was fairly easy.....


store.load({
callback: function (records, operation) {
// alert(records.length);
// alert();


var html = "<div id='bodyContent'>Your Location is:" + center.lat() + center.lng() + "<br/>" + "Sunset time: " + store.data.items[0].data.sunset + " TimeZone " + store.data.items[0].data.timezone + "<br/>hhhgtr</div>";
var marker = new google.maps.Marker({
map: map.map,
position: center
});
var infowindow = new google.maps.InfoWindow({
content: html
});
google.maps.event.addListener(marker, 'click', function () {
infowindow.open(map, marker);
});
infowindow.open(map, marker);
}
});



cheers