Fixed Strategy: can it handle protocol errors?
The default strategy for OpenLayers is Fixed. See for example:
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
})
})
});
Is it possible to pass a callback to handle protocol errors? I can easily do that if I use the low level GET request, for example:
var loadkml = function() {
OpenLayers.Request.GET({
url: "kml/sundials.kml",
success: parseData,开发者_如何学C
failure: function(req) { alert(req.responseText); }
});
}
But I don't want to implement a totally new strategy, Fixed is fine.
The OpenLayers.Protocol.HTTP
protocol accepts a callback
options:
Function to be called when the <read>, <create>, <update>, <delete> or <commit> operation completes
But the function is never called, bug report: https://github.com/openlayers/openlayers/pull/81
精彩评论