【问题标题】:How to upgrade from GML vector layer to VECTOR in OpenLayers如何在 OpenLayers 中从 GML 矢量图层升级到 VECTOR
【发布时间】:2012-08-09 11:13:21
【问题描述】:

根据 OpenLayers,Openlayers.Layer.GML 已被贬值,并且在版本中不受支持。 2.12.我需要移动到矢量图层,但我想不通。

在我之前的版本中,我将其定义为:

           //Locations and UnitLocations layer - GeoJSON
            var LocationStyle = new OpenLayers.Style({
                strokeColor: "#5B5B5B",
                strokeWidth: 1,
                fillColor: "#F4FBA1",
                pointRadius: 10,
                strokeOpacity: 0.8,
                fillOpacity: 0.8,
                label: "${Location}",
                labelYOffset: "-20",
                labelAlign: "cc",
                fontColor: "#000000",
                fontOpacity: 1,
                fontFamily: "Arial",
                fontSize: 12,
                fontWeight: "300"
            });


            var LocationURL = "http://bit.ly/Nfe6IH?q=ICS_Locations&IncidentCode=" + "VAJA%20PSI%2012" + "&key=" + Math.random();
            Locations = new OpenLayers.Layer.GML("Locations", LocationURL, {
                format: OpenLayers.Format.GeoJSON,
                projection: new OpenLayers.Projection("EPSG:4326"), //4326 for WGS84
                styleMap: new OpenLayers.StyleMap(LocationStyle)
            });

在版本中。 Openlayers 2.12 不再支持此功能。你有什么例子我怎么能做到这一点?

谢谢。

【问题讨论】:

  • 可能值得在 gis.stackexchange.com 上询问。那里有更多知识渊博的 OpenLayers 专家!

标签: javascript vector openlayers gml


【解决方案1】:
// format use: new OpenLayers.Format.GPX

                var orange = new OpenLayers.Layer.Vector("gpx", { 
                    protocol: new OpenLayers.Protocol.HTTP({ 
                        url: "mGPX_123123123.gpx", 
                        format: new OpenLayers.Format.GPX
                    }), 
                    strategies: [new OpenLayers.Strategy.Fixed()], 
                    visibility: true,                                         
                    projection: new OpenLayers.Projection("EPSG:4326") 
                }); 
                myMap.addLayer(orange);    

// refer http://osgeo-org.1560.n6.nabble.com/PB-V-2-12-and-Layer-GML-td4984663.html

【讨论】:

  • 这也是一个新的例子! wiki.openstreetmap.org/wiki/Openlayers_Track_example // 添加带有 GPX Track 的层 var lgpx = new OpenLayers.Layer.Vector("Lakeside cycleride", { strategy: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP ({ url: "around_lake.gpx", format: new OpenLayers.Format.GPX() }), style: {strokeColor: "green", strokeWidth: 5, strokeOpacity: 0.5}, projection: new OpenLayers.Projection("EPSG :4326") }); map.addLayer(lgpx);
【解决方案2】:

尝试调整以下代码:

Locations = new OpenLayers.Layer.Vector("Locations", {
                strategies: [new OpenLayers.Strategy.Fixed()], 
                protocol: new OpenLayers.Protocol.HTTP({
                     url: LocationURL,
                     format: new OpenLayers.Format.GeoJSON()

                }),
                displayInLayerSwitcher: false,

            });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多