[OpenLayers-Dev] Plot features onto multiple layers from one HTTP request

Ivan Price Ivan.Price at noveltis.fr
Wed Jun 4 08:13:57 PDT 2014

perform your own ajax call, requesting the 2 layers and getting the single return dictionary/object in something like geojson, then add them to the target layer manually ?

or some knick-nack where there is a 'master layer' that is connected to a url, and another that receives features from it based on an attribute value.


-----Message d'origine-----
De : openlayers-dev-bounces at lists.osgeo.org [mailto:openlayers-dev-bounces at lists.osgeo.org] De la part de khanh703
Envoyé : Wednesday, 4 June 2014 16:50
À : openlayers-dev at lists.osgeo.org
Objet : [OpenLayers-Dev] Plot features onto multiple layers from one HTTP request

I would like to plot features onto multiple layers from one HTTP request ie (Burgers, Hot Dogs, etc...)

I can achieve what I want by making multiple request but would rather make one request.

How can I achieve plotting on different layers:
1. Change the protocol attributes to read from local ARRAY and do a while loop or 2. Change my FeatureCollection structure

This below works but all features are plotted on the same layer:
markers = new OpenLayers.Layer.Vector(thisLayer, {
            preFeatureInsert: preFeatureInsert,
            strategies: [
                new OpenLayers.Strategy.Fixed(),
                new OpenLayers.Strategy.Cluster({
                    distance: 20
            protocol: new OpenLayers.Protocol.HTTP({
                url: protocolUrl,
                format: protocolFormat
            projection: MapProj,
            formatOptions: {
                extractStyles: true,
                extractAttributes: true
            styleMap: new OpenLayers.StyleMap({
                "default": style,
                "select": style
            catID: 0

with this collection:
    "type": "FeatureCollection",
    "features": [{
        "type": "feature",
        "properties": {
            "id": "7943",
            "name": "Bobs Burger",
            "category": "57",
            "color": "9875c3",
            "timestamp": "1400149988"
        "geometry": {
            "type": "Point",
            "coordinates": [-76.437099, 39.041711]
    }, {
        "type": "feature",
        "properties": {
            "id": "7944",
            "name": "Hot Diggity",
            "category": "54",
            "color": "b33838",
            "timestamp": "1400150184"
        "geometry": {
            "type": "Point",
            "coordinates": [-76.436586, 39.041696]

View this message in context: http://osgeo-org.1560.x6.nabble.com/Plot-features-onto-multiple-layers-from-one-HTTP-request-tp5144030.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.
Dev mailing list
Dev at lists.osgeo.org

More information about the Dev mailing list