Sencha Touch + OpenLayers:无法创建包装 Openlayers.request.Get 函数的列表
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请注意,我对所有 ExtJS 和现在的 Sencha 框架仍然是新手。然而,由于您的问题最终可能与我正在使用 OL 和 Sencha Touch 所做的一些工作有关,所以决定看看它。确实找不到任何错误,但我在 Sencha Touch 文档中查找,itemtap 被列为:
那么,您是否尝试过这个而不是您写的内容?
我在这里可能是错的,但也许 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:
So, have you tried this instead of what you wrote?
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.