OpenLayers OpenLayers

Ticket #445 (closed feature: fixed)

Opened 2 years ago

Last modified 1 year ago

controls outside the map view port

Reported by: pgiraud Assigned to: tschaub
Priority: minor Milestone: 2.3 Release
Component: Control Version:
Keywords: Cc:
State:

Description

For now when a control is added to the map its container is happend as a child to the mapViewPort div. OpenLayers should propose a way to allow user to define an element in the HTML page to be used as container for the control. For now, the MousePosition control uses a hacky way to do this.

Here is a patch to get this generically usable.

Note, the patch also proposes an implementation for OverviewMap and MousePosition controls.

Attachments

controls_outside_map.patch.txt (10.2 kB) - added by pgiraud on 12/12/06 08:55:43.
proposed patch
externalControl.patch (0.7 kB) - added by tschaub on 12/12/06 12:46:27.
change map.addControlToMap to allow controls outside viewport

Change History

12/12/06 08:55:43 changed by pgiraud

  • attachment controls_outside_map.patch.txt added.

proposed patch

12/12/06 08:56:14 changed by pgiraud

  • owner changed.
  • component changed from general to Control.
  • milestone set to Vector RC1.

12/12/06 08:57:20 changed by pgiraud

  • milestone deleted.

12/12/06 12:46:27 changed by tschaub

  • attachment externalControl.patch added.

change map.addControlToMap to allow controls outside viewport

12/12/06 12:54:58 changed by tschaub

  • keywords set to review.
  • owner set to tschaub.
  • milestone set to 2.3 Release.

Everything is in place to allow controls to be outside the viewport div. The one exception is the map.addControlToMap method, which appends the control's div to the viewport div without checking if it already has a place in the DOM.

If this check is made in map.addControlToMap, then you can construct a control with a div option, passing an element that already exists in the DOM, and have the control live in that element.

Then, if you want to test whether or not the control lives in the viewport, you can test this.div.parentNode.className == 'olMapViewport' from the control.

Please review.

12/13/06 05:36:05 changed by pgiraud

This sounds good but this in sequence the control.draw() method is called before the div element is happened or not to the viewport. So in the control.draw(), you cannot know if the control will be inside or outside the map but this would be needed for styling or minimize/maximize button for example. Any idea about that ?

12/13/06 11:40:46 changed by tschaub

Ok, think we're settled. You can check for the existence of this.div.parentNode in the control's draw method. If this node doesn't exist, then the control is about to be added to the viewport. If the node exists, you can assume that it is outside of the map's viewport.

12/13/06 13:52:03 changed by tschaub

More explicitly, in a control's draw method, you can use the following condition to determine whether the control is going to end up in the map viewport:

if(!this.div.parentNode  || (this.div.parentNode.className == 'olMapViewport')) {
    // the control will be or already is in the map viewport
}

12/22/06 12:19:50 changed by crschmidt

  • status changed from new to closed.
  • resolution set to fixed.

Closed by r2087

07/05/07 17:07:27 changed by euzuro

  • keywords deleted.