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 create my OpenLayers.Control.OverviewMap with a given size but I would like to change it when certain conditions are met. I have tried two approaches with no luck...

My first try was just changing its width and height via CSS attributes:

$("div.olControlOverviewMapElement>div.olMap").css('width',320);

It does change its visual size but then the overview map doesn't work properly, the "new gained" space in the overviewmap is not usable (can't be used to drag the view rectangle)

My second try was simply changing its size property:

ovMap.size = new OpenLayers.Size(320,240);

but it doesn't have any effect to the overview map.

Is it possible to change its size once it's been created?

Extra information: Using OpenLayers-2.10, and in both cases I have tried calling the update() method of the control.

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

As far as I know, the general rule is that the control size is set when it is created, and after that it cannot be changed.

The only solution I find is that when those conditions are met (a) remove the OverviewMap control (b) create a new one having the desired size and (c) add it to the map.

share|improve this answer
    
(+1) added example in an answer post. –  CaptDragon Jun 22 '11 at 15:42
add comment

This seems to work:

var ovMapControl = map.getControlsBy("CLASS_NAME", "OpenLayers.Control.OverviewMap")[0];
map.removeControl(ovMapControl);

var newOVControl = new OpenLayers.Control.OverviewMap({ 'autoActivate': true });

newOVControl.size = new OpenLayers.Size(320, 240);
map.addControl(newOVControl);
share|improve this answer
    
Personally I find simpler, and prefer, something like var ovMapControl = map.getControlsByClass('OpenLayers.Control.OverviewMap')[0]; –  dariapra Jun 22 '11 at 17:49
    
Thanks for the example! –  arosa Jun 24 '11 at 14:52
add comment

You can maybe try to do something with the isSuitableOverview() method. If not, you could try to fire a function depending on a given event to unset you mapoverview object and create an other one with new options.

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.