我正在使用 geoxml3 加载地图。如果我使用 kml 文件或 xml 字符串,它工作正常
KML 版本(确定)
geoXml_1.parse('kmlFile.kml');
if (geoXml_1.docs[0].gpolygons.length>0){ //NO ERROR IN geoXml_1.docs[0]
[.....]
}else{
[.....]
}
XML 字符串
geoXml_1.parseKmlString("<?xml version='1.0' encoding='UTF-8'?><kml xmlns='http://earth.google.com/kml/2.0'><Placemark><name>Manfred Mustermann</name><description>Manfred Mustermann</description><Point><coordinates>7.0964850607874,51.781641735074,0</coordinates></Point><address>Musterstr 29 Aachen, 52070 Nordrhein-Westfalen</address><styleUrl>#0</styleUrl></Placemark></kml>")
if (geoXml_1.docs[0].gpolygons.length>0){ //NO ERROR IN geoXml_1.docs[0]
[.....]
}else{
[.....]
}
但是,如果我使用 asp 文件来编写 xml,则它不会正常工作。我收到一个 JavaScript 错误:
geoXml_1.parse('/service/map.asp');
返回map.asp
XML 的位置:
/service/map.asp
<%
Response.ContentType = "text/xml"
response.write "<?xml version='1.0' encoding='UTF-8'?><kml xmlns='http://earth.google.com/kml/2.0'><Placemark><name>Manfred Mustermann</name><description>Manfred Mustermann</description><Point><coordinates>7.0964850607874,51.781641735074,0</coordinates></Point><address>Musterstr 29 Aachen, 52070 Nordrhein-Westfalen</address><styleUrl>#0</styleUrl></Placemark></kml>"
%>
使用firebug,输出正常。我可以看到 xml,但在这里出现错误:
geoXml_1.parse('/service/map.asp');
if (geoXml_1.docs[0].gpolygons.length>0){ //ERROR ON FIREBUG: geoXml_1.docs[0] is undefined
[.....]
}else{
[.....]
}
geoxml 真的接受我想做的事吗?可能吗??为什么不?
谢谢!!