not getting all results
Posted: Mon Jan 01, 2007 9:59 pm
hi there.i am having this xml file, http://www.houseonmap.gr/areadata.xml,
and getting the data (X and Y) in this manner
for some reason i am getting only when the wanted id is 1,2,3, 11,22,33 and never for 12,21,23,31,32
If anyone can help it would be great.thanks
and getting the data (X and Y) in this manner
Code: Select all
<select size="1" name="Area" onchange = "javascript: makeRequest(this.value)">
<option value="1" selected>Athens Center</option>
<option value="12">---Kolwnaki</option>
<option value="11">---Plaka</option>
<option value="2">Boreia Proasteia</option>
<option value="21">---Kifisia</option>
<option value="22">---Papagou</option>
<option value="23">---Xalandri</option>
<option value="3">Notia kai Anatoliki Attiki</option>
<option value="31">---Vyrwnas</option>
<option value="32">---Kaisariani</option>
<option value="33">---Zwgrafos</option>
</select>Code: Select all
/*AJAX*/
function getHTTPObject() {
if (typeof XMLHttpRequest != 'undefined') {
return new XMLHttpRequest();
}
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {} } return false;
}
function makeRequest(id_wanted){
var url = "http://www.houseonmap.gr/areadata.xml";
var http_request = getHTTPObject();
http_request.open("GET", url, true);
http_request.onreadystatechange = function() {
if(http_request.readyState == 4) {
if(http_request.status == 200){
GetData(http_request,id_wanted);
}
}
}
http_request.send(null);
}
function GetData(http_request,id_wanted){
map.setZoom(6);
var response = http_request.responseXML;
//GET THE ROOT OF THE DATA
var root = response.documentElement;
var ter_list = root.getElementsByTagName("Territory");
var N = ter_list.length;
var FLAG; //0 is territory 1 is area...moreover when flag = 1 means area found so break out of the loop of the territories
var i;
var j;
var X;
var Y;
var tempTerritory;
var tempArea;
var tempid;
for(i=0;i<N;i++){
if(FLAG == 1) break;
FLAG = 0;
tempTerritory = ter_list[i];
tempid = tempTerritory.getAttribute("id");
if(tempid==id_wanted){
X=tempTerritory.getElementsByTagName("t_X")[0].childNodes[0].nodeValue;
Y=tempTerritory.getElementsByTagName("t_Y")[0].childNodes[0].nodeValue;
FLAG = 0;
break;
}
var area_list = tempTerritory.getElementsByTagName("area");
for(j=0;j<area_list.length;j++){
tempArea = area_list[i];
tempid = tempArea.getAttribute("id");
if(tempid==id_wanted){
X=tempArea.getElementsByTagName("X")[0].childNodes[0].nodeValue;
Y=tempArea.getElementsByTagName("Y")[0].childNodes[0].nodeValue;
FLAG = 1;
break;
}
}
}
document.form1.Acor.value = i;
document.form1.Bcor.value = j;
document.form1.Ccor.value = area_list.length;
document.form1.Dcor.value = FLAG;
document.form1.Ycor.value = Y;
document.form1.Xcor.value = X;
if(FLAG == 0) {map.setZoom(12);}
if(FLAG == 1) {map.setZoom(14);}
map.panTo(new GLatLng(Y, X));
http_request.abort();
}for some reason i am getting only when the wanted id is 1,2,3, 11,22,33 and never for 12,21,23,31,32
If anyone can help it would be great.thanks