【问题标题】:GeoExt reload FeatureStore changing urlGeoExt 重新加载 FeatureStore 更改 url
【发布时间】:2014-07-18 10:02:05
【问题描述】:

我正在尝试重新加载 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 但没有运气。

【问题讨论】:

    标签: openlayers store geoext


    【解决方案1】:

    我明白了! 我必须更换协议:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-19
      • 2016-01-12
      • 1970-01-01
      • 2015-01-19
      • 1970-01-01
      • 2016-02-01
      相关资源
      最近更新 更多