Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.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

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.

share|improve this answer

Your Answer


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.