首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >修复策略:它可以处理协议错误吗?

修复策略:它可以处理协议错误吗?
EN

Stack Overflow用户
提问于 2011-10-05 07:31:43
回答 1查看 925关注 0票数 0

OpenLayers的默认策略是Fixed。例如,请参阅:

http://openlayers.org/dev/examples/sundials.html

代码语言:javascript
复制
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请求,我可以很容易地做到这一点,例如:

代码语言:javascript
复制
var loadkml = function() {
      OpenLayers.Request.GET({
          url: "kml/sundials.kml",
          success: parseData,
          failure: function(req) { alert(req.responseText); }
      });
  }

但我不想实施一种全新的策略,修复就可以了。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-11-30 21:08:43

OpenLayers.Protocol.HTTP协议接受callback选项:

Function to be called when the <read>, <create>, <update>, <delete> or <commit> operation completes

但是这个函数从来没有被调用过,错误报告:https://github.com/openlayers/openlayers/pull/81

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7655191

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档