This is the outside_viewport patch from tschaub for #446:

http://trac.openlayers.org/attachment/ticket/446/outside_viewport.patch

The large diff is because I am suffering under constraints of a bad working
environment. I hate newlines! This patch closes #446.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@2088 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-12-22 17:35:34 +00:00
parent 46767efed2
commit 063a10d4ac

View File

@@ -29,6 +29,15 @@ OpenLayers.Control.OverviewMap.prototype =
*/
ovmap: null,
/**
* The overvew map size in pixels. Note that this is the size of the map
* itself - the element that contains the map (class name
* olControlOverviewMapElement) may have padding or other style attributes
* added via CSS.
* @type OpenLayers.Size
*/
size: new OpenLayers.Size(180, 90),
/**
* Ordered list of layers in the overview map. If none are sent at
* construction, then the default below is used.
@@ -51,6 +60,14 @@ OpenLayers.Control.OverviewMap.prototype =
*/
maxRatio: 32,
/**
* An object containing any non-default properties to be sent to the
* overview map's map constructor. These should include any non-default
* options that the main map was constructed with.
* @type: Object
*/
mapOptions: {},
/**
* @constructor
* @param {Object} options Hashtable of options to set on the overview map
@@ -64,7 +81,6 @@ OpenLayers.Control.OverviewMap.prototype =
*/
draw: function() {
OpenLayers.Control.prototype.draw.apply(this, arguments);
if(!(this.layers.length > 0)) {
if (this.map.baseLayer) {
var layer = this.map.baseLayer.clone();
@@ -81,8 +97,8 @@ OpenLayers.Control.OverviewMap.prototype =
this.element.style.display = 'none';
this.mapDiv = document.createElement('div');
this.mapDiv.style.width = '180px';
this.mapDiv.style.height = '90px';
this.mapDiv.style.width = this.size.w + 'px';
this.mapDiv.style.height = this.size.h + 'px';
this.mapDiv.style.position = 'relative';
this.mapDiv.style.overflow = 'hidden';
this.mapDiv.id = OpenLayers.Util.createUniqueID('overviewMap');
@@ -99,7 +115,6 @@ OpenLayers.Control.OverviewMap.prototype =
this.element.appendChild(this.mapDiv);
this.div.appendChild(this.element);
this.div.className = 'olControlOverviewMapContainer';
this.map.events.register('moveend', this, this.update);
@@ -130,8 +145,11 @@ OpenLayers.Control.OverviewMap.prototype =
this.mapDivEvents = new OpenLayers.Events(this, this.mapDiv);
this.mapDivEvents.register('click', this, this.mapDivClick);
// There should be an option to place the control outside of the
// map viewport. This would make these buttons optional.
// Optionally add min/max buttons if the control will go in the
// map viewport.
if(!this.div.parentNode ||
(this.div.parentNode.className == 'olMapViewport')) {
this.div.className = 'olControlOverviewMapContainer';
var imgLocation = OpenLayers.Util.getImagesLocation();
// maximize button div
var img = imgLocation + 'layer-switcher-maximize.png';
@@ -165,6 +183,10 @@ OpenLayers.Control.OverviewMap.prototype =
this.div.appendChild(this.minimizeDiv);
this.minimizeControl();
} else {
// show the overview map
this.element.style.display = '';
}
return this.div;
},
@@ -369,7 +391,9 @@ OpenLayers.Control.OverviewMap.prototype =
createMap: function() {
// create the overview map
this.ovmap = new OpenLayers.Map(this.mapDiv.id, {controls: [], maxResolution: 'auto'});
var options = OpenLayers.Util.extend(
{controls: [], maxResolution: 'auto'}, this.mapOptions);
this.ovmap = new OpenLayers.Map(this.mapDiv.id, options);
this.ovmap.addLayers(this.layers);
this.ovmap.zoomToMaxExtent();
// check extent rectangle border width
@@ -389,8 +413,10 @@ OpenLayers.Control.OverviewMap.prototype =
* Updates the extent rectangle position and size to match the map extent
*/
updateRectToMap: function() {
// The base layer for overview map needs to be in the same projection
// as the base layer for the main map. This should be made more robust.
if(this.map.units != 'degrees') {
if(this.map.projection != this.ovmap.map.projection) {
if(this.map.getProjection() != this.ovmap.getProjection()) {
alert('The overview map only works when it is in the same projection as the main map');
}
}