Sencha Touch + OpenLayers:无法创建包装 Openlayers.request.Get 函数的列表

发布于 2024-12-02 18:47:27 字数 2401 浏览 1 评论 0原文

我正在使用 Sencha Touch + OpenLayers 开发演示应用程序。其中一项功能是获取GeoServer中要素数据的目录。我想使用 Ext.List 显示要素图层的名称。我尝试了以下代码:

App.AddFeatureLayerList = Ext.extend(Ext.List, {    
createStore: function(){
    Ext.regModel('WFSLayers', {
        fields: ['name', 'title', 'srs', 'featureNS']
    });
    var data = [];
    var request = OpenLayers.Request.GET({
        url: root+'/geoserver/ows?service=wfs&version=1.0.0&request=GetCapabilities',
        handler: function(response){
            var XMLformat = new OpenLayers.Format.XML();
            var xml = XMLformat.read(response.responseText);
            var CAPformat = new OpenLayers.Format.WFSCapabilities();
            cap = CAPformat.read(xml);

            for (var i = 0; i < cap.featureTypeList.featureTypes.length; i++) {
                var featureT = cap.featureTypeList.featureTypes[i];
                data.push({
                    name: featureT.name,
                    title: featureT.title,
                    srs: featureT.srs,
                    featureNS: featureT.featureNS
                });
            }
            return new Ext.data.Store({
                model: 'WFSLayers',
                sorters: 'title',
                data: data,
                getGroupString: function(record){
                    return record.get('title')[0];
                },
            });
        }
    });
},
initComponent: function(){
    this.store = this.createStore();
    this.itemTpl = new Ext.XTemplate('<span class="gx-layer-item">{name}</span>');
    this.grouped = true;
    this.listeners = {
        itemtap: function(dataview, index, item, e){


        }
    };
    App.AddFeatureLayerList.superclass.initComponent.call(this);
}
});
Ext.reg('app_addFeatureLayerList', App.AddFeatureLayerList);

但是,我收到错误:

Uncaught DataView requires tpl, store and itemSelector configurations to be defined.

然后如果我删除代码:

new Ext.data.Store({
            model: 'WFSLayers',
            sorters: 'title',
            data: data,
            getGroupString: function(record){
                return record.get('title')[0];
            },
        });

并在调用“this.createStore()”后将它们传递给 this.store ”,我会得到一个空列表。但是,我跟踪数组data,结果发现它有数据,但存储是空的。

我找不到它有什么问题。有人可以帮我给我一些提示吗?

感谢所有帮助!

I am using Sencha Touch + OpenLayers to develop a demo app. One feature is to get the catalog of feature data in GeoServer. I want to use Ext.List to display the name of feature layers. I tried following codes:

App.AddFeatureLayerList = Ext.extend(Ext.List, {    
createStore: function(){
    Ext.regModel('WFSLayers', {
        fields: ['name', 'title', 'srs', 'featureNS']
    });
    var data = [];
    var request = OpenLayers.Request.GET({
        url: root+'/geoserver/ows?service=wfs&version=1.0.0&request=GetCapabilities',
        handler: function(response){
            var XMLformat = new OpenLayers.Format.XML();
            var xml = XMLformat.read(response.responseText);
            var CAPformat = new OpenLayers.Format.WFSCapabilities();
            cap = CAPformat.read(xml);

            for (var i = 0; i < cap.featureTypeList.featureTypes.length; i++) {
                var featureT = cap.featureTypeList.featureTypes[i];
                data.push({
                    name: featureT.name,
                    title: featureT.title,
                    srs: featureT.srs,
                    featureNS: featureT.featureNS
                });
            }
            return new Ext.data.Store({
                model: 'WFSLayers',
                sorters: 'title',
                data: data,
                getGroupString: function(record){
                    return record.get('title')[0];
                },
            });
        }
    });
},
initComponent: function(){
    this.store = this.createStore();
    this.itemTpl = new Ext.XTemplate('<span class="gx-layer-item">{name}</span>');
    this.grouped = true;
    this.listeners = {
        itemtap: function(dataview, index, item, e){


        }
    };
    App.AddFeatureLayerList.superclass.initComponent.call(this);
}
});
Ext.reg('app_addFeatureLayerList', App.AddFeatureLayerList);

However, i got an error:

Uncaught DataView requires tpl, store and itemSelector configurations to be defined.

then if I remove the codes:

new Ext.data.Store({
            model: 'WFSLayers',
            sorters: 'title',
            data: data,
            getGroupString: function(record){
                return record.get('title')[0];
            },
        });

and put them to pass to this.store after call "this.createStore()", I will get a empty list. however, I traced array data and it turns out it has data, but the store is empty.

I can't find what's wrong with it. Anybody could help me give me some hints?

Appreciate all help!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缺⑴份安定 2024-12-09 18:47:27

请注意,我对所有 ExtJS 和现在的 Sencha 框架仍然是新手。然而,由于您的问题最终可能与我正在使用 OL 和 Sencha Touch 所做的一些工作有关,所以决定看看它。确实找不到任何错误,但我在 Sencha Touch 文档中查找,itemtap 被列为:

itemtap( Ext.DataView this, Number index, Ext.Element item, Ext.EventObject e )

那么,您是否尝试过这个而不是您写的内容?

itemtap: function( this, index, item, e ) 

我在这里可能是错的,但也许 Sencha 正在抱怨,因为它认为你正在声明一个尚未定义的新数据视图(?)。我认为这就是错误所抱怨的。如果这是问题所在,请感兴趣。

Be advised I'm still a newbie here with all the ExtJS and now Sencha framework. However, as your question may be related eventually to some work I'm doing with OL and Sencha Touch, decided to look at it. Couldn't really find anything wrong but I was looking in the Sencha Touch docs and the itemtap is listed as:

itemtap( Ext.DataView this, Number index, Ext.Element item, Ext.EventObject e )

So, have you tried this instead of what you wrote?

itemtap: function( this, index, item, e ) 

I could be wrong here but perhaps Sencha is complaining because it thinks you're declaring a new dataview which hasn't been defined yet(?). I think that's what the error is complaining about. Be interested if that was the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文