繁体   English   中英

UTM和GeoJson在openlayers中

[英]UTM and GeoJson in openlayers

我想实现此示例http://api.geoext.org/1.1/examples/feature-grid.html,由geoext和openlayers组成,该要素网格填充了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
            });

如您所见,我尝试指定要素存储的内部和外部投影,我的实现类似于上面提到的链接的示例,但是当我选择城市时,地图位于错误的位置(显示的位置在南极附近,但必须在南美洲附近)

提前致谢

由于什么原因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,并且请求将包含可见区域的边界框,因此您只能发送将变为可见的要素,而不是所有要素。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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