2

我想实现这个由geoext和openlayers组成的例子http://api.geoext.org/1.1/examples/feature-grid.html,该特征网格由geojson文件填充

在我的开发中,我有一个 utm 格式的 geojson 文件,这是我文件的一个特征(坐标是 utm)

{"geometry": {"type": "Point", "coordinates": [7535169.36, 402844.172]}, "type": "Feature", "properties": {"NOMBRE": "LA VICTORIA", "CODIGO": "1702"}, "id": "1702"}

我试图在我的代码中显示要点,但我什么也看不到,这是我的代码

// create feature store, binding it to the vector layer
            store = new GeoExt.data.FeatureStore({
                layer: vecCiudades,
                fields: [
                    { name: 'NOMBRE' },
                    { name: 'CODIGO' }
                ],
                proxy: new GeoExt.data.ProtocolProxy({
                    protocol: new OpenLayers.Protocol.HTTP({
                        url: "data/summits.json",
                        format: new OpenLayers.Format.GeoJSON({
                            ignoreExtraDims: true,
                            internalProjection: new OpenLayers.Projection("EPSG:900913"),
                            externalProjection: new OpenLayers.Projection("EPSG:4326")
                        })
                    })
                }),
                autoLoad: true
            });

如您所见,我尝试指定功能商店的内部和外部投影,我的实现看起来像上面提到的链接示例,但是当我选择一个城市时,地图位于错误的地方(显示的地方靠近南极,但必须靠近南美洲)

提前致谢

4

1 回答 1

0

为什么FeatureStore..?只需定义图层如下:

var vecCiudades = new OpenLayers.Layer.Vector('MyLayer', {
    strategies:[new OpenLayers.Strategy.BBOX()],
    isBaseLayer:false,
    projection:new OpenLayers.Projection("EPSG:900913"),
    styleMap:new OpenLayers.StyleMap(null),
    transitionEffect:'resize',
    protocol:new OpenLayers.Protocol.HTTP({
        url: "data/summits.json",
        format:new OpenLayers.Format.GeoJSON({
            ignoreExtraDims:true
        }),
        readWithPOST:false,
        updateWithPOST:false,
        srsInBBOX:true
    })
});

同时在地图上注册以下活动:

map.events.register("moveend", this, function (e) {
    vecCiudades.refresh({force:true});
});

这将在任何时候重新读取 GeoJSON 移动或缩放的地图,并且请求将包含可见区域的边界框,因此您只能发送将不可见的特征而不是所有特征。

于 2012-07-07T21:34:47.830 回答