Add a new option to Control.OverviewMap to start maximized. r=bartvde (closes #2746)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10674 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -75,15 +75,13 @@
|
|||||||
map1.addControl(new OpenLayers.Control.LayerSwitcher());
|
map1.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||||
|
|
||||||
// create an overview map control with the default options
|
// create an overview map control with the default options
|
||||||
var overview1 = new OpenLayers.Control.OverviewMap();
|
var overview1 = new OpenLayers.Control.OverviewMap({
|
||||||
|
maximized: true
|
||||||
|
});
|
||||||
map1.addControl(overview1);
|
map1.addControl(overview1);
|
||||||
|
|
||||||
map1.setCenter(new OpenLayers.LonLat(0, 0), 2);
|
map1.setCenter(new OpenLayers.LonLat(0, 0), 2);
|
||||||
|
|
||||||
// expand the overview map control
|
|
||||||
overview1.maximizeControl();
|
|
||||||
|
|
||||||
|
|
||||||
// create the bottom map (with advanced overview map control)
|
// create the bottom map (with advanced overview map control)
|
||||||
var mapOptions = {
|
var mapOptions = {
|
||||||
maxExtent: new OpenLayers.Bounds(-8242894.927728, 4965204.031195,
|
maxExtent: new OpenLayers.Bounds(-8242894.927728, 4965204.031195,
|
||||||
@@ -99,6 +97,7 @@
|
|||||||
|
|
||||||
// create an overview map control with non-default options
|
// create an overview map control with non-default options
|
||||||
var controlOptions = {
|
var controlOptions = {
|
||||||
|
maximized: true,
|
||||||
mapOptions: OpenLayers.Util.extend(mapOptions, {
|
mapOptions: OpenLayers.Util.extend(mapOptions, {
|
||||||
maxResolution: 156543.0339,
|
maxResolution: 156543.0339,
|
||||||
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
|
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
|
||||||
@@ -111,9 +110,6 @@
|
|||||||
|
|
||||||
map2.setCenter(new OpenLayers.LonLat(-8233165.3575055, 4980298.21113769), 3);
|
map2.setCenter(new OpenLayers.LonLat(-8233165.3575055, 4980298.21113769), 3);
|
||||||
|
|
||||||
// expand the overview map control
|
|
||||||
overview2.maximizeControl();
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -120,6 +120,12 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
*/
|
*/
|
||||||
resolutionFactor: 1,
|
resolutionFactor: 1,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIProperty: maximized
|
||||||
|
* {Boolean} Start as maximized (visible). Defaults to false.
|
||||||
|
*/
|
||||||
|
maximized: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor: OpenLayers.Control.OverviewMap
|
* Constructor: OpenLayers.Control.OverviewMap
|
||||||
* Create a new overview map
|
* Create a new overview map
|
||||||
@@ -288,7 +294,10 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.map.events.register('moveend', this, this.update);
|
this.map.events.register('moveend', this, this.update);
|
||||||
|
|
||||||
|
if (this.maximized) {
|
||||||
|
this.maximizeControl();
|
||||||
|
}
|
||||||
return this.div;
|
return this.div;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -147,6 +147,32 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_initialize_maximized(t) {
|
||||||
|
t.plan(4);
|
||||||
|
|
||||||
|
control = new OpenLayers.Control.OverviewMap()
|
||||||
|
map = new OpenLayers.Map('map', {
|
||||||
|
layers : [new OpenLayers.Layer("layer", {isBaseLayer: true})],
|
||||||
|
controls: [control]
|
||||||
|
});
|
||||||
|
|
||||||
|
t.eq(control.maximized, false, "OverviewMap is not maximized by default");
|
||||||
|
t.eq(control.element.style.display, 'none', "OverviewMap.element is not visible");
|
||||||
|
map.destroy();
|
||||||
|
|
||||||
|
control = new OpenLayers.Control.OverviewMap({
|
||||||
|
maximized: true
|
||||||
|
})
|
||||||
|
map = new OpenLayers.Map('map', {
|
||||||
|
layers : [new OpenLayers.Layer("layer", {isBaseLayer: true})],
|
||||||
|
controls: [control]
|
||||||
|
});
|
||||||
|
t.eq(control.maximized, true, "OverviewMap.maximized is set");
|
||||||
|
t.eq(control.element.style.display, '', "OverviewMap.element is visible");
|
||||||
|
|
||||||
|
map.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in New Issue
Block a user