2012-08-09 108 views
2

根據OpenLayers的說法,Openlayers.Layer.GML已經過折舊,並且在Ver。 2.12。我需要移動到矢量圖層,但我無法弄清楚。如何從OpenLayers中的GML矢量圖層升級到VECTOR

在我以前的版本我已經把它定義爲:

  //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版本不再支持。你有什麼樣的例子,我怎麼能做到這一點?

謝謝。

+0

可能是值得一問這對gis.stackexchange.com。在那裏有更多知識淵博的OpenLayers專家! – 2012-08-09 14:35:00

回答

0

嘗試以下調整代碼:

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, 

      }); 
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 
+0

這裏也是一個新的例子! http://wiki.openstreetmap.org/wiki/Openlayers_Track_example //添加與GPX軌道 \t \t \t變種lgpx =新OpenLayers.Layer.Vector( 「湖濱週期搭」 的層,{ \t \t \t \t策略:[新OpenLayers.Strategy.Fixed()], \t \t \t \t協議:新OpenLayers.Protocol.HTTP({ \t \t \t \t \t URL: 「around_lake.gpx」, \t \t \t \t \t格式:新OpenLayers.Format.GPX() \t \t \t \t}), \t \t \t \t式:{則strokeColor: 「綠色」,strokeWidth:5,strokeOpacity,用於:0.5}, \t \t \t \t projection:new OpenLayers.Projection(「EPSG:4326」) \t \t \t}); \t \t \t map.addLayer(lgpx); – 2012-08-27 18:25:52

相關問題