这是我的代码。我从 xml 获取数据。但它不起作用..请看看哪里有错误。
我找不到它..我正在研究它一个多星期...
但什么都没有:(
PS对不起我的英语..
这是我的 XML 数据..
<marker>
<line id_line="1" colour="#ccc" width="4" users="line" coordinats="47.828979,40.974844;47.839451,40.985211;47.848377,40.981064;47.853699,40.984822">
<point lng="40.974844" lat="47.828979"/>
<point lng="40.985211" lat="47.839451"/>
<point lng="40.981064" lat="47.848377"/>
<point lng="40.984822" lat="47.853699"/>
</line>
</marker>
JavaScript:
function line() {
var point=[];
downloadUrl("line.php", function(data) {
var xml = data.responseXML;
var markers = xmlDoc.documentElement.getElementsByTagName("marker");
var lines = xmlDoc.documentElement.getElementsByTagName("line");
for (var a = 0; a < lines.length; a++) {
var colour = lines[a].getAttribute("colour");
var width = parseFloat(lines[a].getAttribute("width"));
var points = lines[a].getElementsByTagName("point");
alert (points[i].getAttribute("lat"));
var pts = [];
for (var i = 0; i < points.length; i++) {
pts[i] = new google.maps.LatLng(parseFloat(points[i].getAttribute("lat")),
parseFloat(points[i].getAttribute("lng")));
}
new google.maps.Polyline(pts,colour,width);
pts.setMap(map);
}
google.maps.event.addListener(pointpath,'mouseover', function() {
this.setOptions({strokeColor: '#3ADF00' });
this.setOptions({strokeOpacity: 1.0 });
this.setOptions({strokeWeight: 4 });
});
google.maps.event.addListener(pointpath,'mouseout', function() {
this.setOptions({strokeColor: '#FF0040' });
this.setOptions({strokeOpacity: 1.0 });
this.setOptions({strokeWeight: 2 });
});
var mpenc = new google.maps.InfoWindow();
var contentString = "Status: " + status ;
google.maps.event.addListener(pointpath,'click', function(event) {
mpenc.setContent(contentString);
mpenc.setPosition(event.latLng);
mpenc.open(map);
});
}
});
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
}