简体   繁体   中英

GeoExt reload FeatureStore changing url

I'm trying to reload a GeoExt.data.FeatureStore changing url. This is my code:

 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();
        });

I can see the request is made in Firebug console, but the url is "/url" not "/url2" as I expect. Also tried with

store.proxy.url = "url2";

since FeatureStore inherit from Ext.data.Store but no luck.

I've got it! I have to replace the protocol:

 mycombo.addListener('change', function() {
        var proto = new OpenLayers.Protocol.HTTP({
            url: new_url,
            format: new OpenLayers.Format.GeoJSON()
        });
        vecLayer.protocol = proto;
        vecLayer.refresh();
 });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM