Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I set up a GML layer with local GeoJSON file as data source:

veclayer = new OpenLayers.Layer.GML("vector", "localfile.json",
{
    format: OpenLayers.Format.GeoJSON,
    strategies: [new OpenLayers.Strategy.fixed()],
    styleMap: myStyleMap
});

Then later I change some of the attributes of GeoJSON data in the veclayer:

veclayer.features[i].attributes.someAttr = value;

After all features are updated, I want to redraw the layer. I see some examples that uses the following method:

function UpdateVecLayer(layer) {
        layer.loaded = false;
        layer.setVisibility(true);
        layer.refresh({force: true, params:{'key': Math.random()}});
    }

However, it doesn't work for me. I think it is because when I reload the layer, it just loads the local file again, and the attribute values are not changed. Can anyone tell me how to update the layer?

share|improve this question
    
Are you modifying geometries? Do you really need to redraw the layer? –  simo Nov 14 '11 at 12:21
    
No, I don't modify geometries. I only modify attributes. And the layer is rendered according to the attribute. How can the layer show differently if not redrawn? –  ChanDon Nov 14 '11 at 13:27
add comment

1 Answer

Because GML layer is extended by Vector layer you can use strategies to save changes. Probably this is possible to make it, but I never do it with local file.

http://dev.openlayers.org/apidocs/files/OpenLayers/Strategy/Save-js.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.