0

我正在尝试重新加载 GeoExt.data.FeatureStore 更改 url。这是我的代码:

 var vecLayer = new OpenLayers.Layer.Vector("vector", {
            protocol: new OpenLayers.Protocol.HTTP({
                url: '/url',
                format: new OpenLayers.Format.GeoJSON()
            }),
            strategies: [new OpenLayers.Strategy.Fixed()]
        });

 var store = Ext.create('GeoExt.data.FeatureStore', {
        layer: vecLayer,
        fields: [
            {name: 'name', type: 'string'},
            {name: 'elevation', type: 'float'}
        ],
        autoLoad: true
    });

 mycombo.addListener('change', function() {
            vecLayer.protocol.url = "/url2";
            vecLayer.refresh();
        });

我可以看到请求是在 Firebug 控制台中发出的,但 url 是“/url”而不是“/url2”,正如我所料。也试过了

store.proxy.url = "url2";

因为 FeatureStore 继承自 Ext.data.Store 但没有运气。

4

1 回答 1

0

我懂了!我必须更换协议:

 mycombo.addListener('change', function() {
        var proto = new OpenLayers.Protocol.HTTP({
            url: new_url,
            format: new OpenLayers.Format.GeoJSON()
        });
        vecLayer.protocol = proto;
        vecLayer.refresh();
 });
于 2014-07-28T13:32:58.143 回答