sg

Cuma, Ocak 13, 2006

XMLHttpRequest Basics - authorization issue?


I am very new to this whole thing and by no means a star developer, so
any help would be greatly appreciated. I am trying to display a map
with custom markers that come out of an XML file. I used some of the
examples on the API documentation pages to produce the code below.

The problem i am having is that, although the map does show, the
markers never show up. If I add an alert(readyState) function, it sends
out 0, then 1, then 2, then 3, but stops there.

Any idea what would cause the XML request to never finish? The XML file
is very small, so could it be a problem with my web host?

Thanks!!!

//****************************************
function onLoad() {
if (GBrowserIsCompatible()) {
var icon = new GIcon();
icon.image = "myicon.jpg";
icon.iconSize = new GSize(23, 16);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(5, 1);

// Set the maps center and extent
var map = new GMap(document.getElementById("map"));
map.centerAndZoom(new GPoint(-87.675362,41.909559), 4);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());

// function to create a marker and a click event
function createMarker(point,label) {
var marker = new GMarker(point, icon);
GEvent.addListener(marker, 'click', function()
{marker.openInfoWindowHtml(label);});
return marker;
}

var request = GXmlHttp.create();
request.open('GET', 'data.xml', true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
var xmlDoc = request.responseXML;
var markers =
xmlDoc.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var point = new
GPoint(parseFloat(markers[i].getAttribute("lng")),parseFloat(markers[i].getAttribute("lat")));
var marker = new GMarker(point,icon);
map.addOverlay(marker);
}
}
else{
//alert(request.readyState);
}
}
request.send(null);
}
}
//****************************************

0 Comments:

Yorum Gönder

<< Home


Komik Videolar   islam  şarkı sözleri  yemek tarifleri  gelibolu  huzur   sağlık