如何从OpenLayers中的GML矢量图层升级到VECTOR
根据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版本不再支持。你有什么样的例子,我怎么能做到这一点?
谢谢。
尝试以下调整代码:
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,
});
// 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
这里也是一个新的例子! 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
可能是值得一问这对gis.stackexchange.com。在那里有更多知识渊博的OpenLayers专家! – 2012-08-09 14:35:00