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); }
});
}
但我不想实施一个全新的策略,固定没问题。
答案 0 :(得分:2)
OpenLayers.Protocol.HTTP
协议接受callback
个选项:
Function to be called when the <read>, <create>, <update>, <delete> or <commit> operation completes
但该函数永远不会被调用,bug报告:https://github.com/openlayers/openlayers/pull/81