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:
@@ -29,6 +29,15 @@ OpenLayers.Control.OverviewMap.prototype =
|
|||||||
*/
|
*/
|
||||||
ovmap: null,
|
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
|
* Ordered list of layers in the overview map. If none are sent at
|
||||||
* construction, then the default below is used.
|
* construction, then the default below is used.
|
||||||
@@ -51,6 +60,14 @@ OpenLayers.Control.OverviewMap.prototype =
|
|||||||
*/
|
*/
|
||||||
maxRatio: 32,
|
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
|
* @constructor
|
||||||
* @param {Object} options Hashtable of options to set on the overview map
|
* @param {Object} options Hashtable of options to set on the overview map
|
||||||
@@ -64,7 +81,6 @@ OpenLayers.Control.OverviewMap.prototype =
|
|||||||
*/
|
*/
|
||||||
draw: function() {
|
draw: function() {
|
||||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||||
|
|
||||||
if(!(this.layers.length > 0)) {
|
if(!(this.layers.length > 0)) {
|
||||||
if (this.map.baseLayer) {
|
if (this.map.baseLayer) {
|
||||||
var layer = this.map.baseLayer.clone();
|
var layer = this.map.baseLayer.clone();
|
||||||
@@ -81,8 +97,8 @@ OpenLayers.Control.OverviewMap.prototype =
|
|||||||
this.element.style.display = 'none';
|
this.element.style.display = 'none';
|
||||||
|
|
||||||
this.mapDiv = document.createElement('div');
|
this.mapDiv = document.createElement('div');
|
||||||
this.mapDiv.style.width = '180px';
|
this.mapDiv.style.width = this.size.w + 'px';
|
||||||
this.mapDiv.style.height = '90px';
|
this.mapDiv.style.height = this.size.h + 'px';
|
||||||
this.mapDiv.style.position = 'relative';
|
this.mapDiv.style.position = 'relative';
|
||||||
this.mapDiv.style.overflow = 'hidden';
|
this.mapDiv.style.overflow = 'hidden';
|
||||||
this.mapDiv.id = OpenLayers.Util.createUniqueID('overviewMap');
|
this.mapDiv.id = OpenLayers.Util.createUniqueID('overviewMap');
|
||||||
@@ -99,7 +115,6 @@ OpenLayers.Control.OverviewMap.prototype =
|
|||||||
this.element.appendChild(this.mapDiv);
|
this.element.appendChild(this.mapDiv);
|
||||||
|
|
||||||
this.div.appendChild(this.element);
|
this.div.appendChild(this.element);
|
||||||
this.div.className = 'olControlOverviewMapContainer';
|
|
||||||
|
|
||||||
this.map.events.register('moveend', this, this.update);
|
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 = new OpenLayers.Events(this, this.mapDiv);
|
||||||
this.mapDivEvents.register('click', this, this.mapDivClick);
|
this.mapDivEvents.register('click', this, this.mapDivClick);
|
||||||
|
|
||||||
// There should be an option to place the control outside of the
|
// Optionally add min/max buttons if the control will go in the
|
||||||
// map viewport. This would make these buttons optional.
|
// map viewport.
|
||||||
|
if(!this.div.parentNode ||
|
||||||
|
(this.div.parentNode.className == 'olMapViewport')) {
|
||||||
|
this.div.className = 'olControlOverviewMapContainer';
|
||||||
var imgLocation = OpenLayers.Util.getImagesLocation();
|
var imgLocation = OpenLayers.Util.getImagesLocation();
|
||||||
// maximize button div
|
// maximize button div
|
||||||
var img = imgLocation + 'layer-switcher-maximize.png';
|
var img = imgLocation + 'layer-switcher-maximize.png';
|
||||||
@@ -165,6 +183,10 @@ OpenLayers.Control.OverviewMap.prototype =
|
|||||||
this.div.appendChild(this.minimizeDiv);
|
this.div.appendChild(this.minimizeDiv);
|
||||||
|
|
||||||
this.minimizeControl();
|
this.minimizeControl();
|
||||||
|
} else {
|
||||||
|
// show the overview map
|
||||||
|
this.element.style.display = '';
|
||||||
|
}
|
||||||
|
|
||||||
return this.div;
|
return this.div;
|
||||||
},
|
},
|
||||||
@@ -369,7 +391,9 @@ OpenLayers.Control.OverviewMap.prototype =
|
|||||||
|
|
||||||
createMap: function() {
|
createMap: function() {
|
||||||
// create the overview map
|
// 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.addLayers(this.layers);
|
||||||
this.ovmap.zoomToMaxExtent();
|
this.ovmap.zoomToMaxExtent();
|
||||||
// check extent rectangle border width
|
// 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
|
* Updates the extent rectangle position and size to match the map extent
|
||||||
*/
|
*/
|
||||||
updateRectToMap: function() {
|
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.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');
|
alert('The overview map only works when it is in the same projection as the main map');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user