Question

My project is geographic maps application. This is my protocol:

var myprotocol = new OpenLayers.Protocol.HTTP({
    url: url,
    format: new OpenLayers.Format.GeoJSON({
        extractStyles: true,
        extractAttributes: true
    })     
});

This is my layer function:

var layer = new OpenLayers.Layer.Vector("layerName", {
     projection: epsg4326,
     strategies: strategies, 
     protocol: myprotocol, 
     displayInLayerSwitcher: true         
});

layer.events.register('loadend', layer, function (evt) {
    console.log("onloadend was called");
});

layer.events.register('loadstart', layer, function (evt) {
    console.log("onloadstart was called");    
}

This is my other function:

myprotocol.read({
    // maxFeatures: 100,
    callback: function (resp) {
        console.log("read  _CallBack was called");
        console.log(resp);         
    }
});

myprotocol.handleResponse = function (resp, opt) {
    console.log("handleResponse   was called");      
};

These are my attributes:

var data = new Object();
data.iconUrl = katman.iconUrl;
data.fillColor = katman.fillColor;
data.fillOpacity = katman.fillOpacity;
data.graphicHeight = katman.graphicHeight;
data.graphicOpacity = katman.graphicOpacity;
data.graphicWidth = katman.graphicWidth;
data.graphicXOffset = katman.graphicXOffset;
data.graphicYOffset = katman.graphicYOffset;
data.pointRadius = katman.pointRadius;
data.pointerEvents = katman.pointerEvents;
data.rotation = katman.rotation;
data.strokeColor = katman.strokeColor;
data.strokeDashstyle = katman.strokeDashstyle;
data.strokeLinecap = katman.strokeLinecap;
data.strokeOpacity = katman.strokeOpacity;
data.strokeWidth = katman.strokeWidth;
data.layerId = feature.data.layerId;
data.shapeId = feature.data.shapeId;

I want to add this attributes for each feature that I received featurecollection object from web service.

No correct solution

OTHER TIPS

I've solved this problem with the following code.thank you for help me..

  myprotocol.handleResponse = function (resp, opt) {
        console.log("handleResponse   was called");


        var features = geojson.read(resp.priv.responseText);
        for (var i in features) {
            var feature = features[i];
            feature.attributes.iconUrl = katman.iconUrl;
            feature.attributes.fillColor = katman.fillColor;
            feature.attributes.fillOpacity = katman.fillOpacity;
            feature.attributes.graphicHeight = katman.graphicHeight;
            feature.attributes.graphicOpacity = katman.graphicOpacity;
            feature.attributes.graphicWidth = katman.graphicWidth;
            feature.attributes.graphicXOffset = katman.graphicXOffset;
            feature.attributes.graphicYOffset = katman.graphicYOffset;
            feature.attributes.pointRadius = katman.pointRadius;
            feature.attributes.pointerEvents = katman.pointerEvents;
            feature.attributes.rotation = katman.rotation;
            feature.attributes.strokeColor = katman.strokeColor;
            feature.attributes.strokeDashstyle = katman.strokeDashstyle;
            feature.attributes.strokeLinecap = katman.strokeLinecap;
            feature.attributes.strokeOpacity = katman.strokeOpacity;
            feature.attributes.strokeWidth = katman.strokeWidth;

        }
        layer.addFeatures(features);

    };
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top