Stop using deprecated Layer.GML in examples

This commit is contained in:
fredj
2011-11-18 11:24:33 +01:00
parent 9f836cd264
commit 7f7f946c29
2 changed files with 21 additions and 16 deletions

View File

@@ -50,21 +50,20 @@
style.addRules([rule, elseRule]);
// Create a GML layer with GeoRSS format and a style map.
markerLayer = new OpenLayers.Layer.GML("Some images from Flickr",
"xml/georss-flickr.xml", {
format: OpenLayers.Format.GeoRSS,
formatOptions: {
// adds the thumbnail attribute to the feature
createFeatureFromItem: function(item) {
var feature = OpenLayers.Format.GeoRSS.prototype
.createFeatureFromItem.apply(this, arguments);
feature.attributes.thumbnail =
this.getElementsByTagNameNS(
item, "*", "thumbnail")[0].getAttribute("url");
return feature;
}
},
// Create a Vector layer with GeoRSS format and a style map.
markerLayer = new OpenLayers.Layer.Vector("Some images from Flickr", {
protocol: new OpenLayers.Protocol.HTTP({
url: "xml/georss-flickr.xml",
format: new OpenLayers.Format.GeoRSS({
// adds the thumbnail attribute to the feature
createFeatureFromItem: function(item) {
var feature = OpenLayers.Format.GeoRSS.prototype.createFeatureFromItem.apply(this, arguments);
feature.attributes.thumbnail = this.getElementsByTagNameNS(item, "*", "thumbnail")[0].getAttribute("url");
return feature;
}
})
}),
strategies: [new OpenLayers.Strategy.Fixed()],
// Giving the style map keys for "default" and "select"
// rendering intent, to make the image larger when selected
styleMap: new OpenLayers.StyleMap({

View File

@@ -20,7 +20,13 @@
"http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer);
map.zoomToExtent(new OpenLayers.Bounds(-3.922119,44.335327,4.866943,49.553833));
map.addLayer(new OpenLayers.Layer.GML("GML", "gml/polygon.xml"));
map.addLayer(new OpenLayers.Layer.Vector("GML", {
protocol: new OpenLayers.Protocol.HTTP({
url: "gml/polygon.xml",
format: new OpenLayers.Format.GML()
}),
strategies: [new OpenLayers.Strategy.Fixed()]
}));
}
</script>
</head>