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.

Using OpenLayers is it possible to draw a rectange that will always be on one portion of map without regards to zooming and panning of map?

share|improve this question
    
You could use a div & position it using CSS. That might be the easiest option. –  Devdatta Tengshe Sep 27 '12 at 7:28
    
@DevdattaTengshe I want it to be redrawn like any layer. –  kinkajou Sep 27 '12 at 8:53
    
Why do you want it to redraw, if it is not going to change its position on the screen? and you can always toggle its visibility when the map pans or zooms to give a similar effect. –  Devdatta Tengshe Sep 27 '12 at 9:05
    
@DevdattaTengshe IF it's layer itself then I will be able to print it and redraw it when it's value change using timer. –  kinkajou Sep 27 '12 at 9:09
add comment

2 Answers

up vote 4 down vote accepted

It is like the car window in a race game? Here a red box

 <div style="z-index:99999999; position:fixed; 
             top:300px; right:300px; width:80px; height:80px;
             border-color:red; border-style:solid; border-width:2px;
 ">&nbsp;</div>

Change position to relative (a div into the map's div) if you need it scrolling with the page, p. ex.

 position:relative; z-index:99999999; top:30px; right:-40px; 

See also z-index at map layers, CSS positioning, and box model.

share|improve this answer
    
How can I make this div movable with mouse?? –  kinkajou Sep 27 '12 at 10:51
    
It is "like a STATIONARY window" :-) Well, your question is about drawing a rectangle "that will always be on certain area", so it is stationary. For "animation" (you need to post a new question!) the div must have a ID and you can use jQuery to control it. PS: about playing this question-and-answer-game, my answer is acceptable? –  Peter Krauss Sep 27 '12 at 12:18
add comment

One option is to use the Vector layer, and set its isFixed property to true. This way the vector layer will not move around when the map is dragged, but is printed and redrawn with the map.

share|improve this answer
    
I will try this .. it seems good –  kinkajou Oct 9 '12 at 6:09
    
"Note that setting this to true will move the layer to the bottom of the layer stack" so if I have opaque layer on top then it will block eveything :(. I Need it on the top. –  kinkajou Oct 9 '12 at 10:00
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.