I am new to OpenLayers. In one experiment I am doing I want to load, incrementally, features in a vector layer. In my setting, these features should be loaded from distinct OSM files (generated dynamically) in a HTTP server.
I know how to create a vector layer from a single OSM file, I have done it with a code similar to this:
...
map = new OpenLayers.Map('map_element', {
maxResolution: 156543.0399,
numZoomLevels: 16,
units: 'm',
projection: new OpenLayers.Projection('EPSG:900913'),
displayProjection: new OpenLayers.Projection('EPSG:4326')
});
vectorLayer = new OpenLayers.Layer.Vector("POIs", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "my_dynamically_generated_osm_file.osm",
format: new OpenLayers.Format.OSM()
}),
projection: new OpenLayers.Projection("EPSG:4326")
});
map.addLayers([<other_layers_here>, vectorLayer]);
...
However, I am wondering how I can create first the vector layer without features, and afterwards adding new features defined in different OSM files according to the requests of the user. I know vector layer objects have a method addFeatures()
, so I just need to know how could I obtain these features from the distinct OSM files provided by my http server ?