[OpenLayers-Commits] r5155 - sandbox/jachym/openlayers/lib/OpenLayers/Control
commits at openlayers.org
commits at openlayers.org
Fri Nov 9 03:25:17 EST 2007
Author: jachym
Date: 2007-11-09 03:25:13 -0500 (Fri, 09 Nov 2007)
New Revision: 5155
Modified:
sandbox/jachym/openlayers/lib/OpenLayers/Control/PanZoomBar.js
Log:
zoomWorld icon enabled
Modified: sandbox/jachym/openlayers/lib/OpenLayers/Control/PanZoomBar.js
===================================================================
--- sandbox/jachym/openlayers/lib/OpenLayers/Control/PanZoomBar.js 2007-11-08 21:18:31 UTC (rev 5154)
+++ sandbox/jachym/openlayers/lib/OpenLayers/Control/PanZoomBar.js 2007-11-09 08:25:13 UTC (rev 5155)
@@ -1,6 +1,6 @@
-/* Copyright (c) 2006-2007 MetaCarta, Inc., published under a modified BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
- * for the full text of the license. */
+/* Copyright (c) 2006-2007 MetaCarta, Inc., published under the Clear BSD
+ * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
+ * full text of the license. */
/**
@@ -47,6 +47,12 @@
*/
divEvents: null,
+ /**
+ * Property: zoomWorldIcon
+ * {Boolean}
+ */
+ zoomWorldIcon: false,
+
/**
* Constructor: <OpenLayers.Control.PanZoomBar>
*/
@@ -72,7 +78,7 @@
this.divEvents = null;
this.map.events.unregister("zoomend", this, this.moveZoomBar);
- this.map.events.unregister("changebaselayer", this, this.redraw)
+ this.map.events.unregister("changebaselayer", this, this.redraw);
OpenLayers.Control.PanZoom.prototype.destroy.apply(this, arguments);
},
@@ -115,11 +121,21 @@
var sz = new OpenLayers.Size(18,18);
var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y);
+ var wposition = sz.w;
+ if (this.zoomWorldIcon) {
+ centered = new OpenLayers.Pixel(px.x+sz.w, px.y);
+ }
+
this._addButton("panup", "north-mini.png", centered, sz);
px.y = centered.y+sz.h;
this._addButton("panleft", "west-mini.png", px, sz);
- this._addButton("panright", "east-mini.png", px.add(sz.w, 0), sz);
+ if (this.zoomWorldIcon) {
+ this._addButton("zoomworld", "zoom-world-mini.png", px.add(sz.w, 0), sz);
+
+ wposition *= 2;
+ }
+ this._addButton("panright", "east-mini.png", px.add(wposition, 0), sz);
this._addButton("pandown", "south-mini.png", centered.add(0, sz.h*2), sz);
this._addButton("zoomin", "zoom-plus-mini.png", centered.add(0, sz.h*3+5), sz);
centered = this._addZoomBar(centered.add(0, sz.h*4 + 5));
@@ -152,10 +168,10 @@
this.sliderEvents.register("dblclick", this, this.doubleClick);
this.sliderEvents.register("click", this, this.doubleClick);
- sz = new OpenLayers.Size();
+ var sz = new OpenLayers.Size();
sz.h = this.zoomStopHeight * this.map.getNumZoomLevels();
sz.w = this.zoomStopWidth;
- var div = null
+ var div = null;
if (OpenLayers.Util.alphaHack()) {
var id = "OpenLayers_Control_PanZoomBar" + this.map.id;
@@ -211,7 +227,9 @@
* and sets the zoom level appropriately.
*/
divClick: function (evt) {
- if (!OpenLayers.Event.isLeftClick(evt)) return;
+ if (!OpenLayers.Event.isLeftClick(evt)) {
+ return;
+ }
var y = evt.xy.y;
var top = OpenLayers.Util.pagePosition(evt.object)[1];
var levels = Math.floor((y - top)/this.zoomStopHeight);
@@ -227,7 +245,9 @@
* evt - {<OpenLayers.Event>}
*/
zoomBarDown:function(evt) {
- if (!OpenLayers.Event.isLeftClick(evt)) return;
+ if (!OpenLayers.Event.isLeftClick(evt)) {
+ return;
+ }
this.map.events.register("mousemove", this, this.passEventToSlider);
this.map.events.register("mouseup", this, this.passEventToSlider);
this.mouseDragStart = evt.xy.clone();
@@ -250,7 +270,7 @@
*/
zoomBarDrag:function(evt) {
if (this.mouseDragStart != null) {
- var deltaY = this.mouseDragStart.y - evt.xy.y
+ var deltaY = this.mouseDragStart.y - evt.xy.y;
var offsets = OpenLayers.Util.pagePosition(this.zoombarDiv);
if ((evt.clientY - offsets[1]) > 0 &&
(evt.clientY - offsets[1]) < parseInt(this.zoombarDiv.style.height) - 2) {
@@ -271,12 +291,14 @@
* evt - {<OpenLayers.Event>}
*/
zoomBarUp:function(evt) {
- if (!OpenLayers.Event.isLeftClick(evt)) return;
+ if (!OpenLayers.Event.isLeftClick(evt)) {
+ return;
+ }
if (this.zoomStart) {
this.div.style.cursor="";
this.map.events.unregister("mouseup", this, this.passEventToSlider);
this.map.events.unregister("mousemove", this, this.passEventToSlider);
- var deltaY = this.zoomStart.y - evt.xy.y
+ var deltaY = this.zoomStart.y - evt.xy.y;
this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight));
this.moveZoomBar();
this.mouseDragStart = null;
More information about the Commits
mailing list