0
OpenLayers的默认策略是固定的。例如见:固定策略:它可以处理协议错误吗?
http://openlayers.org/dev/examples/sundials.html
var sundials = new OpenLayers.Layer.Vector("KML", {
projection: map.displayProjection,
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "kml/sundials.kml",
format: new OpenLayers.Format.KML({
extractStyles: true,
extractAttributes: true
})
})
});
是否有可能通过一个回调来处理协议错误? 我可以很容易做到,如果我用的是低层次的GET请求,例如:
var loadkml = function() {
OpenLayers.Request.GET({
url: "kml/sundials.kml",
success: parseData,
failure: function(req) { alert(req.responseText); }
});
}
但我不想要实现一个全新的战略,固定的罚款。