Skip to content

Commit 71b737d

Browse files
committed
Merge pull request #292 from bentrm/overview
Make GeoExt.Overview inherit from Ext.Component
2 parents ffb5510 + b3bea8b commit 71b737d

File tree

9 files changed

+68
-72
lines changed

9 files changed

+68
-72
lines changed

examples/overview/overview-generic.html renamed to examples/overviewmap/overview-generic.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,22 @@
1919
<script type="text/javascript" src="../loader.js"></script>
2020
<script type="text/javascript" src="overview-generic.js"></script>
2121
<style>
22-
.gx-overview .olControlOverviewMapElement {
22+
.gx-overview-map .olControlOverviewMapElement {
2323
padding: 0;
2424
background-color: rgba(0, 0, 0, 0.5)
2525
}
2626
</style>
2727
</head>
2828
<body>
2929
<div id="desc">
30-
<h1>GeoExt.container.Overview Components</h1>
31-
<p>This example shows how to work with the overview component. It inherits
32-
from Ext.container.Container wrapping the OpenLayers Overview control. This means
30+
<h1>GeoExt.OverviewMap Components</h1>
31+
<p>This example shows how to work with the OverviewMap component. It inherits
32+
from Ext.Component wrapping the OpenLayers Overview control. This means
3333
you can place it in your applications layout as you would any other component.
34-
The example shows the usage inside a vbox layout, so the components size is
34+
The example shows the usage of an GeoExt.OverviewMap as an item of a
35+
Ext.panel.Panel inside a vbox layout. The overviews map size is ultimately
3536
determined by the parents dimensions.<br>
36-
The overview has not been configured with a map so it defaults to the
37+
The OverviewMap component has not been configured with a map so it defaults to the
3738
GeoExt.panel.Map guessed at runtime.<p>
3839
<p>The js is not minified so it is readable. See
3940
<a href="overview-generic.js">overview-generic.js</a>.</p>

examples/overview/overview-generic.js renamed to examples/overviewmap/overview-generic.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Ext.require([
22
'Ext.container.Viewport',
33
'GeoExt.panel.Map',
4-
'GeoExt.container.Overview'
4+
'GeoExt.OverviewMap'
55
]);
66

77
Ext.application({
@@ -56,7 +56,7 @@ Ext.application({
5656
title: 'Overview',
5757
flex: 1,
5858
layout: 'fit',
59-
items: { xtype: 'gx_overview' }
59+
items: { xtype: 'gx_overviewmap' }
6060
}
6161
]
6262
}

examples/overview/overview.html renamed to examples/overviewmap/overview.html

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>GeoExt Overview Example</title>
4+
<title>GeoExt.OverviewMap Example</title>
55

66
<!-- ExtJS -->
77
<script type="text/javascript" src="http://cdn.sencha.com/ext/gpl/4.2.1/examples/shared/include-ext.js"></script>
@@ -19,22 +19,23 @@
1919
<script type="text/javascript" src="../loader.js"></script>
2020
<script type="text/javascript" src="overview.js"></script>
2121
<style>
22-
.gx-overview .olControlOverviewMapElement {
22+
.gx-overview-map .olControlOverviewMapElement {
2323
padding: 0;
2424
background-color: rgba(0, 0, 0, 0.5)
2525
}
2626
</style>
2727
</head>
2828
<body>
2929
<div id="desc">
30-
<h1>GeoExt.container.Overview Components</h1>
31-
<p>This example shows how to work with the overview component. It inherits
32-
from Ext.container.Container wrapping the OpenLayers Overview control. This means
30+
<h1>GeoExt.OverviewMap Components</h1>
31+
<p>This example shows how to work with the OverviewMap component. It inherits
32+
from Ext.Component wrapping the OpenLayers OverviewMap control. This means
3333
you can place it in your applications layout as you would any other component.
3434
The example shows the usage as a floating, resizable component positioned
35-
absolutely above the map. The second container has been placed inside a vbox layout,
36-
so the components size is determined by the parents dimensions.<br>
37-
The floating overview map has been configured as "dynamic" which means it will
35+
absolutely above the map. The second GeoExt.OverviewMap has been placed as a
36+
panels item inside a vbox layout, so the components size is determined by
37+
the parents dimensions.<br>
38+
The floating OverviewMap has been configured as "dynamic" which means it will
3839
update itself to show the bound maps active baselayer.<p>
3940
<p>The js is not minified so it is readable. See
4041
<a href="overview.js">overview.js</a>.</p>

examples/overview/overview.js renamed to examples/overviewmap/overview.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Ext.require([
22
'Ext.container.Viewport',
33
'GeoExt.panel.Map',
4-
'GeoExt.container.Overview'
4+
'GeoExt.OverviewMap'
55
]);
66

77
Ext.application({
@@ -38,7 +38,7 @@ Ext.application({
3838
});
3939

4040
// Customized floating overview container
41-
var overview = Ext.create('GeoExt.container.Overview', {
41+
var overview = Ext.create('GeoExt.OverviewMap', {
4242
map: map,
4343
dynamic: true,
4444
autoShow: true,
@@ -111,15 +111,15 @@ Ext.application({
111111
flex: 1,
112112
layout: 'fit',
113113
items: [{
114-
xtype: 'gx_overview'
114+
xtype: 'gx_overviewmap'
115115
}]
116116
}
117117
]
118118
}
119119
]
120120
});
121121

122-
// Positioning the floating container relative to the viewport
122+
// Positioning the floating component relative to the viewport
123123
var vOffset = -25 - overview.getHeight();
124124
var position = overview.getAlignToXY(viewport, 'bl', [25, vOffset]);
125125
overview.setPosition(position);

resources/css/overview.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

resources/css/overviewmap.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.gx-overview-map .olControlOverviewMapElement {
2+
padding: 0;
3+
}

src/GeoExt/container/Overview.js renamed to src/GeoExt/OverviewMap.js

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,30 @@
77
*/
88

99
/**
10-
* A container encapsulating an OpenLayers.Control.OverviewMap control.
10+
* A component encapsulating an OpenLayers.Control.OverviewMap control.
1111
*
1212
* When you use this component in an application, make sure to include the
13-
* stylesheet 'overview.css' or add the following to your own stylesheet.
13+
* stylesheet 'overviewmap.css' or add the following to your own stylesheet.
1414
*
1515
* <code>
16-
* .gx-overview .olControlOverviewMapElement { padding: 0; }
16+
* .gx-overview-map .olControlOverviewMapElement { padding: 0; }
1717
* </code>
1818
*
19-
* @class GeoExt.container.Overview
19+
* @class GeoExt.OverviewMap
2020
*/
21-
Ext.define('GeoExt.container.Overview', {
22-
extend: 'Ext.container.Container',
23-
alias: 'widget.gx_overview',
21+
Ext.define('GeoExt.OverviewMap', {
22+
extend: 'Ext.Component',
23+
alias: 'widget.gx_overviewmap',
24+
requires: [
25+
'GeoExt.Version'
26+
],
2427

2528
/**
2629
* Custom CSS class added to this components #cls.
2730
*
2831
* @property {String}
2932
*/
30-
ovCls: 'gx-overview',
31-
32-
/**
33-
* The default layout of the Overview component.
34-
*
35-
* @property {String}
36-
*/
37-
layout: 'fit',
33+
ovCls: 'gx-overview-map',
3834

3935
/**
4036
* The OpenLayers.Map that this overview is bound to. If not set by the user
@@ -63,7 +59,7 @@ Ext.define('GeoExt.container.Overview', {
6359
* - "size" will default to the containers actual dimensions
6460
* - "maximized" will always be true to make the overview visible
6561
*
66-
* If you want to hide the overview map, simple use the containers show/hide
62+
* If you want to hide the overview map, simple use the components show/hide
6763
* methods.
6864
*
6965
* @cfg {Object}
@@ -85,8 +81,8 @@ Ext.define('GeoExt.container.Overview', {
8581
// add gx class making sure it won't be overridden on accident
8682
this.addCls(this.ovCls);
8783

88-
// bind to the containers events to make sure the overview is added
89-
// and removed when the container is (in-)visible.
84+
// bind to the components lifecycle events to make sure the overview is
85+
// added and removed from the map when the component is (in-)visible.
9086
this.on({
9187
'show': this.reinitControl,
9288
'resize': this.reinitControl,
@@ -106,8 +102,8 @@ Ext.define('GeoExt.container.Overview', {
106102

107103
/**
108104
* Destroys the encapsulated OpenLayers.Control.OverviewMap removing it from
109-
* the maps controls and unbinding all mapped events from this component.
110-
* Deletes the containers map and overviewOptions members.
105+
* the map controls and unbinds all events from this component.
106+
* Deletes the components ctrl, map and overviewOptions members.
111107
*
112108
* @private
113109
*/
@@ -163,9 +159,7 @@ Ext.define('GeoExt.container.Overview', {
163159
// not set by user, the overview control will fail on construction.
164160
// This is to determine any layer to be shown in overview map.
165161
if (map.allOverlays) {
166-
if (!options.layers
167-
&& map.layers
168-
&& map.layers.length > 0) {
162+
if (!options.layers && map.layers && map.layers.length > 0) {
169163
baselayer = map.layers[0].clone();
170164
baselayer.setIsBaseLayer(true);
171165
options.layers = [ baselayer ];

tests/container/Overview.html renamed to tests/OverviewMap.html

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
disableCaching: false,
1212
enabled: true,
1313
paths: {
14-
GeoExt: '../../src/GeoExt'
14+
GeoExt: '../src/GeoExt'
1515
}
1616
});
1717

1818
Ext.Loader.syncRequire([
1919
'GeoExt.panel.Map',
20-
'GeoExt.container.Overview'
20+
'GeoExt.OverviewMap'
2121
]);
2222

2323
function test_lifecycle(t) {
@@ -46,28 +46,28 @@
4646
map: map
4747
});
4848

49-
var overview = Ext.create('GeoExt.container.Overview', {
49+
var overview = Ext.create('GeoExt.OverviewMap', {
5050
floating: true,
5151
width: 300,
5252
height: 150,
5353
map: map
5454
});
5555

5656
t.ok(map.getControlsByClass('OpenLayers.Control.OverviewMap').length === 0,
57-
'no overview control is added to the map if overview container is not shown');
57+
'no overview control is added to the map if overview component is not shown');
5858

5959
try {
6060
overview.show();
61-
t.ok(true, 'can show overview container');
61+
t.ok(true, 'can show overview component');
6262
} catch (err) {
63-
t.ok(false, 'showing an overview container leads to', err);
63+
t.ok(false, 'showing an overview component leads to', err);
6464
}
6565

6666
t.ok(map.getControlsByClass('OpenLayers.Control.OverviewMap').length === 1,
67-
'one overview control is added to the map when overview container is shown');
67+
'one overview control is added to the map when overview component is shown');
6868

6969
t.ok(overview.ctrl.ovmap.layers[0].id !== map.layers[0].id,
70-
'baselayer of overview map is not the same as bounds map baselayer');
70+
'baselayer of overview map is not the same as the bounds map baselayer');
7171

7272
t.ok(overview.ctrl.ovmap.layers[0].name === map.layers[0].name,
7373
'clone of baselayer of bound map is used in overview map');
@@ -78,26 +78,26 @@
7878

7979
try {
8080
overview.hide();
81-
t.ok(true, 'hiding the overview container works fine');
81+
t.ok(true, 'hiding the overview component works fine');
8282
} catch (err) {
83-
t.ok(false, 'hiding the overview container leads to ', err);
83+
t.ok(false, 'hiding the overview component leads to ', err);
8484
}
8585

8686
t.ok(map.getControlsByClass('OpenLayers.Control.OverviewMap').length === 0,
87-
'overview control has been removed from bound map when container is hidden');
87+
'overview control has been removed from bound map when component is hidden');
8888

8989
// move map to check if overview reinits at correct center
9090
map.setCenter([51, 13]);
9191

9292
try {
9393
overview.show();
94-
t.ok(true, 'showing the overview container after it has been hidden');
94+
t.ok(true, 'showing the overview component after it has been hidden');
9595
} catch (err) {
96-
t.ok(false, 'showing an overview container after it has been hidden leads to', err);
96+
t.ok(false, 'showing an overview component after it has been hidden leads to', err);
9797
}
9898

9999
t.ok(map.getControlsByClass('OpenLayers.Control.OverviewMap').length === 1,
100-
'one overview control is been readded to the map when overview container is shown');
100+
'one overview control is been readded to the map when overview component is shown');
101101

102102
t.ok(overview.ctrl.ovmap.layers[0].id !== map.layers[0].id,
103103
'baselayer of overview map is not the same as bounds map baselayer');
@@ -111,7 +111,7 @@
111111

112112
try {
113113
overview.destroy();
114-
t.ok(true, 'overview container can be destroyed');
114+
t.ok(true, 'overview component can be destroyed');
115115
} catch (err) {
116116
t.ok('destroying component leads to ', err);
117117
}
@@ -137,28 +137,28 @@
137137
});
138138

139139
// guess map at runtime
140-
var overview = Ext.create('GeoExt.container.Overview', {
140+
var overview = Ext.create('GeoExt.OverviewMap', {
141141
floating: true,
142142
width: 300,
143143
height: 150,
144144
cls: 'custom-user-cls'
145145
});
146146

147-
t.ok(overview.hasCls('custom-user-cls'));
148-
t.ok(overview.hasCls('gx-overview'));
147+
t.ok(overview.hasCls('custom-user-cls'), 'Custom cls parameter is set.');
148+
t.ok(overview.hasCls('gx-overview-map'), 'GX cls parameter is set.');
149149

150150
t.ok(mapPanel.map.getControlsByClass('OpenLayers.Control.OverviewMap').length === 0,
151-
'no overview control is added to the map if overview container is not shown');
151+
'no overview control is added to the map if overview component is not shown');
152152

153153
try {
154154
overview.show();
155-
t.ok(true, 'can show overview container');
155+
t.ok(true, 'can show overview component');
156156
} catch (err) {
157-
t.ok(false, 'showing an overview container leads to', err);
157+
t.ok(false, 'showing an overview component leads to', err);
158158
}
159159

160160
t.ok(mapPanel.map.getControlsByClass('OpenLayers.Control.OverviewMap').length === 1,
161-
'one overview control is added to the map when overview container is shown');
161+
'one overview control is added to the map when overview component is shown');
162162

163163
}
164164

@@ -183,7 +183,7 @@
183183
var extent = [0, 0, 180, 90];
184184

185185
// guess map at runtime
186-
var overview = Ext.create('GeoExt.container.Overview', {
186+
var overview = Ext.create('GeoExt.OverviewMap', {
187187
floating: true,
188188
width: 300,
189189
height: 150,
@@ -197,9 +197,9 @@
197197

198198
try {
199199
overview.show();
200-
t.ok(true, 'can show overview container');
200+
t.ok(true, 'can show overview component');
201201
} catch (err) {
202-
t.ok(false, 'showing an overview container leads to', err);
202+
t.ok(false, 'showing an overview component leads to', err);
203203
}
204204

205205
t.ok(overview.ctrl.autoPan === true,

tests/list-tests.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<ul id="testlist">
22
<li>Action.html</li>
33
<li>container/LayerLegend.html</li>
4-
<li>container/Overview.html</li>
54
<li>container/UrlLegend.html</li>
65
<li>container/WmsLegend.html</li>
76
<li>container/VectorLegend.html</li>
@@ -30,6 +29,7 @@
3029
<li>grid/column/Symbolizer.html</li>
3130
<li>Lang.html</li>
3231
<li>LegendImage.html</li>
32+
<li>OverviewMap.html</li>
3333
<li>panel/Map.html</li>
3434
<li>panel/Legend.html</li>
3535
<li>panel/PrintMapPanel.html</li>

0 commit comments

Comments
 (0)