2

According to OpenLayers the Openlayers.Layer.GML is depreciated and not supported in ver. 2.12. I need to move to Vector layer, but I can't figure it out.

In my previous version I have defined it as:

           //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)
            });

In ver. 2.12 of Openlayers this is not supported any more. Do you have any example how can I accomplish that?

Thank you.

Matej
  • 227
  • 1
  • 4
  • 11

2 Answers2

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
Pica Mio
  • 51
  • 2
  • And here is a new example too! http://wiki.openstreetmap.org/wiki/Openlayers_Track_example // Add the Layer with the GPX Track var lgpx = new OpenLayers.Layer.Vector("Lakeside cycle ride", { strategies: [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); – Pica Mio Aug 27 '12 at 18:25
0

Try to adjust code below:

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,

            });
Odoakr
  • 382
  • 1
  • 13