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've crated a map and tried, but it doesn't change until another event is caught or zooming map or by switching the browser tabs. What is the reason for this. please help me I've fiddle the code here

This is what I've done to change marker :{
                featureselected: function (event) {
                    var fixer = confirm("Are you want to change clolor this marker");
                    if (fixer == true) {
                        size = new OpenLayers.Size(21, 25);
               = { externalGraphic: "", graphicHeight: 25, graphicWidth: 21, graphicXOffset: -((size.w / 2) - 2), graphicYOffset: -(size.h - 2) };

Thanks in advance.

share|improve this question
up vote 1 down vote accepted

You need to call the redraw method after changing the style.

And you are close. Redraw gets called for you when you zoom, but you have to force it manually when changing style or feature properties.

share|improve this answer
Thanks for helping me. – bios Aug 11 '12 at 13:11

I got vectorLayer.redraw() to work on your jsFiddle from the jsFiddle code:

... = { externalGraphic : "", graphicHeight : 25, graphicWidth : 21, graphicXOffset : -((size.w / 2) - 2), graphicYOffset : -(size.h - 2) }; } vectorLayer.redraw(); } }); ....

share|improve this answer
Thanks for helping me. – bios Aug 11 '12 at 13:12

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.