[Commits] r2249 - in sandbox/mapgears/geoext.ux/ux/ZoomTo: examples lib/GeoExt.ux/widgets resources/lang
commits at geoext.org
commits at geoext.org
Fri Jul 30 21:43:36 CEST 2010
Author: adube
Date: 2010-07-30 21:43:36 +0200 (Fri, 30 Jul 2010)
New Revision: 2249
Added:
sandbox/mapgears/geoext.ux/ux/ZoomTo/resources/lang/fr.js
Modified:
sandbox/mapgears/geoext.ux/ux/ZoomTo/examples/ZoomToExample.html
sandbox/mapgears/geoext.ux/ux/ZoomTo/examples/ZoomToExample.js
sandbox/mapgears/geoext.ux/ux/ZoomTo/lib/GeoExt.ux/widgets/ZoomTo.js
Log:
GeoExt.ux.ZoomTo, proj support, i18n added, defaultZoomLevel, destroyMarker
Modified: sandbox/mapgears/geoext.ux/ux/ZoomTo/examples/ZoomToExample.html
===================================================================
--- sandbox/mapgears/geoext.ux/ux/ZoomTo/examples/ZoomToExample.html 2010-07-30 18:30:59 UTC (rev 2248)
+++ sandbox/mapgears/geoext.ux/ux/ZoomTo/examples/ZoomToExample.html 2010-07-30 19:43:36 UTC (rev 2249)
@@ -14,10 +14,20 @@
<script type="text/javascript" src="../resources/lang/fr.js"></script>
<script type="text/javascript" src="../../../../geoext/lib/GeoExt.js"></script>
+ <!-- proj4js -->
+ <script type="text/javascript" src="../../../../proj4js/trunk/lib/proj4js-compressed.js"></script>
+ <script type="text/javascript" src="../../../../proj4js/trunk/lib/projCode/tmerc.js"></script>
+ <script type="text/javascript" src="../../../../proj4js/trunk/lib/projCode/merc.js"></script>
+ <script type="text/javascript" src="../../../../proj4js/trunk/lib/defs/EPSG42304.js"></script>
+ <script type="text/javascript" src="../../../../proj4js/trunk/lib/defs/EPSG900913.js"></script>
+
+ <!-- ZoomTo lib, css and i18n -->
<link rel="stylesheet" type="text/css" href="../resources/css/ZoomTo.css" />
<script type="text/javascript" src="../lib/GeoExt.ux/SingleFile.js"></script>
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA3mOTdOkDlYkDjNn8Pnmr6RSx-0TMqGjMArKjswQRjIfEFr4DRBQbnmTwDEUT7Xj85OddpLMNrWtXoA'></script>
+ <script type="text/javascript" src="../resources/lang/fr.js"></script>
+
<script type="text/javascript" src="ZoomToExample.js"></script>
</head>
@@ -37,5 +47,19 @@
</p>
<div id="content"></div>
+
+ <p>
+ Chicoutimi (EPSG:42304), <b>X</b>: 1731386.25 <b>Y</b>: 263787.0625
+ </p>
+
+ <p>
+ To demonstrate that the widget supports i18n,
+ <a href="../resources/lang/fr.js">fr.js</a> was loaded.
+ </p>
+
+ <p>
+ In order to be able to reproject in other projections than
+ <b>EPSG:4326</b> and <b>EPSG:900913</b>, proj4js is required.
+ </p>
</body>
</html>
Modified: sandbox/mapgears/geoext.ux/ux/ZoomTo/examples/ZoomToExample.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/ZoomTo/examples/ZoomToExample.js 2010-07-30 18:30:59 UTC (rev 2248)
+++ sandbox/mapgears/geoext.ux/ux/ZoomTo/examples/ZoomToExample.js 2010-07-30 19:43:36 UTC (rev 2249)
@@ -29,14 +29,16 @@
projStore = new Ext.data.SimpleStore({
fields: ['projection'],
data : [
+ ['EPSG:4326'],
['EPSG:900913'],
- ['EPSG:4326'],
- ['EPSG:32198']
+ ['EPSG:42304']
]
});
+ /* ZoomTo widget */
zoomTo = new GeoExt.ux.ZoomTo({
- //'projectionStore': projStore,
+ 'projectionStore': projStore,
+ 'defaultZoomLevel': 10,
'map': map
});
toolbar.add(zoomTo);
Modified: sandbox/mapgears/geoext.ux/ux/ZoomTo/lib/GeoExt.ux/widgets/ZoomTo.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/ZoomTo/lib/GeoExt.ux/widgets/ZoomTo.js 2010-07-30 18:30:59 UTC (rev 2248)
+++ sandbox/mapgears/geoext.ux/ux/ZoomTo/lib/GeoExt.ux/widgets/ZoomTo.js 2010-07-30 19:43:36 UTC (rev 2249)
@@ -22,8 +22,47 @@
*/
GeoExt.ux.ZoomTo = Ext.extend(Ext.Action, {
- text: "ZoomTo",
+ /* begin i18n */
+ /** api: config[zoomToText] ``String`` i18n */
+ zoomToText: "ZoomTo",
+ /** api: config[xCoordinateText] ``String`` i18n */
+ xCoordinateText: "X coordinate",
+
+ /** api: config[yCoordinateText] ``String`` i18n */
+ yCoordinateText: "Y coordinate",
+
+ /** api: config[projectionText] ``String`` i18n */
+ projectionText: "Projection",
+
+ /** api: config[invalidEntryText] ``String`` i18n */
+ invalidEntryText: "invalid entry",
+
+ /** api: config[widgetTitleText] ``String`` i18n */
+ widgetTitleText: "ZoomTo widget",
+
+ /** api: config[destroyMarkerActionText] ``String`` i18n */
+ destroyMarkerActionText: "Remove +",
+
+ /** api: config[closeActionText] ``String`` i18n */
+ closeActionText: "Close",
+
+ /** api: config[zoomActionText] ``String`` i18n */
+ zoomActionText: "Zoom",
+
+ /** api: config[errorText] ``String`` i18n */
+ errorText: "Error",
+
+ /** api: config[missingProjectionText] ``String`` i18n */
+ missingProjectionText: "The projection is missing.",
+
+ /** api: config[missingCoordsText] ``String`` i18n */
+ missingCoordsText: "Missing or invalid coordinates.",
+
+ /** api: config[outOfRangCoordsText] ``String`` i18n */
+ outOfRangCoordsText: "Coordinates are out of current extent range.",
+ /* end i18n */
+
/** private: property[window]
* ``Ext.Window``
*/
@@ -44,6 +83,11 @@
*/
projectionStore: null,
+ /** private: property[defaultZoomLevel]
+ * ``Integer``
+ */
+ defaultZoomLevel: null,
+
/** private: property[autoHideWindowOnZoom]
* ``Boolean``
* If set to true, hides the window after recentering.
@@ -67,18 +111,16 @@
/** private: method[constructor]
*/
constructor: function(config) {
+ Ext.apply(this, config);
+
this.initMap();
arguments.callee.superclass.constructor.call(this, config);
this.setHandler(this.onActionClick, this);
- if (config.projectionStore) {
- this.projectionStore = config.projectionStore;
- }
-
if (this.useIcons === true) {
this.setIconClass("gx-zoomto-recenteroncoords");
} else {
- this.setText(this.text);
+ this.setText(this.zoomToText);
}
},
@@ -130,13 +172,13 @@
labelAlign: 'top',
bodyStyle:'padding:5px 5px 0',
items: [{
- fieldLabel: 'X coordinate',
+ fieldLabel: this.xCoordinateText,
name: 'coordx'
},{
- fieldLabel: 'Y coordinate',
- name: 'coordy'
+ fieldLabel: this.yCoordinateText,
+ name: 'coordy'
},{
- fieldLabel: 'Projection',
+ fieldLabel: this.projectionText,
name: 'projection',
value: defaultProj,
xtype: 'combo',
@@ -147,37 +189,60 @@
forceSelection: true,
triggerAction: 'all',
allowBlank: false,
- invalidText: "invalid entry",
+ invalidText: this.invalidEntryText,
emptyText: "",
selectOnFocus:true
}
]
});
+ var windowButtons = [];
+
+ // remove marker button (optional)
+ if (this.showCenter === true) {
+ windowButtons.push({
+ text: this.destroyMarkerActionText,
+ scope: this,
+ handler: function(){
+ this.destroyMarker();
+ }
+ });
+ }
+
+ // close button
+ /*
+ windowButtons.push({
+ text: this.closeActionText,
+ scope: this,
+ handler: function(){
+ this.window.hide();
+ }
+ });
+ */
+
+ // zoom button
+ windowButtons.push({
+ text: this.zoomActionText,
+ scope: this,
+ handler: function(){
+ this.recenter();
+ }
+ });
+
// Window with buttons
this.window = new Ext.Window({
- title: 'ZoomTo widget',
+ title: this.widgetTitleText,
layout: 'form',
width: 200,
- height: 250,
+ autoHeight: true,
+ height: 'auto',
closeAction: 'hide',
modal: false,
plain: false,
resizable: false,
+ buttonAlign: 'center',
items: [this.form],
- buttons: [{
- text: 'Close',
- scope: this,
- handler: function(){
- this.window.hide();
- }
- },{
- text:'Zoom',
- scope: this,
- handler: function(){
- this.recenter();
- }
- }]
+ buttons: windowButtons
});
}
@@ -191,7 +256,7 @@
var values = this.form.getForm().getValues();
if (values.projection == "") {
- this.showError(OpenLayers.i18n('mf.recenter.missingProj'));
+ this.showError(this.missingProjectionText);
return false;
}
@@ -211,6 +276,8 @@
resolution = OpenLayers.Util.getResolutionFromScale(values.scaleValue,
this.map.units);
zoom = this.map.getZoomForResolution(resolution);
+ } else if (this.defaultZoomLevel) {
+ zoom = this.defaultZoomLevel;
}
this.recenterOnCoords(x, y, zoom);
@@ -261,7 +328,7 @@
checkCoords: function(x, y) {
if (!x || !y) {
- this.showError(OpenLayers.i18n('mf.recenter.missingCoords'));
+ this.showError(this.missingCoordsText);
return false;
}
@@ -269,16 +336,7 @@
if (x < maxExtent.left || x > maxExtent.right ||
y < maxExtent.bottom || y > maxExtent.top) {
- this.showError(OpenLayers.i18n('mf.recenter.outOfRangeCoords', {
- 'myX': x,
- 'myY': y,
- 'coordX': OpenLayers.i18n('mf.recenter.x'),
- 'coordY': OpenLayers.i18n('mf.recenter.y'),
- 'minCoordX': maxExtent.left,
- 'maxCoordX': maxExtent.right,
- 'minCoordY': maxExtent.bottom,
- 'maxCoordY': maxExtent.top
- }));
+ this.showError(this.outOfRangCoordsText);
return false;
}
@@ -341,7 +399,7 @@
*/
prepareVectorLayer: function() {
if (this.vectorLayer) {
- this.vectorLayer.destroyFeatures();
+ this.destroyMarker();
} else {
var styles = new OpenLayers.StyleMap({
"default": OpenLayers.Util.extend({
@@ -364,6 +422,15 @@
}
},
+ /** private: method[destroyMarker]
+ * Removes existing features from vector layer
+ */
+ destroyMarker: function() {
+ if (this.vectorLayer) {
+ this.vectorLayer.destroyFeatures();
+ }
+ },
+
/** private: method[showError]
* Displays an error message
*
@@ -372,7 +439,7 @@
* title - {String} box title
*/
showError: function(msg, title) {
- title = title || OpenLayers.i18n('mf.error');
+ title = title || this.errorText;
Ext.Msg.alert(title, msg);
}
});
Added: sandbox/mapgears/geoext.ux/ux/ZoomTo/resources/lang/fr.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/ZoomTo/resources/lang/fr.js (rev 0)
+++ sandbox/mapgears/geoext.ux/ux/ZoomTo/resources/lang/fr.js 2010-07-30 19:43:36 UTC (rev 2249)
@@ -0,0 +1,18 @@
+Ext.namespace("GeoExt.ux")
+if (GeoExt.ux.ZoomTo) {
+ Ext.apply(GeoExt.ux.ZoomTo.prototype, {
+ zoomToText: "Zoomer",
+ xCoordinateText: "Coordonnée X",
+ yCoordinateText: "Coordonnée Y",
+ projectionText: "Projection",
+ invalidEntryText: "entrée invalide",
+ widgetTitleText: "Outil de zoom sur coordonnées",
+ destroyMarkerActionText: "Effacer +",
+ closeActionText: "Fermer",
+ zoomActionText: "Zoomer",
+ errorText: "Erreur",
+ missingProjectionText: "La projection est manquante.",
+ missingCoordsText: "Coordonnées manquantes ou invalides.",
+ outOfRangCoordsText: "Coordonnées à l'extérieur de l'extent courant."
+ });
+}
More information about the Commits
mailing list