固定策略:它能处理协议错误吗?
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); }
});
}
但我不想实施全新的策略,固定就可以了。
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,
failure: function(req) { alert(req.responseText); }
});
}
But I don't want to implement a totally new strategy, Fixed is fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
OpenLayers.Protocol.HTTP
协议接受回调
选项:当、、时调用的函数<删除>或<提交>操作完成
但该函数从未被调用,错误报告:https://github.com /openlayers/openlayers/pull/81
The
OpenLayers.Protocol.HTTP
protocol accepts acallback
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