[Mapbender-commits] r8108 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Sep 7 03:29:10 EDT 2011
Author: kmq
Date: 2011-09-07 00:29:10 -0700 (Wed, 07 Sep 2011)
New Revision: 8108
Modified:
trunk/mapbender/http/javascripts/mod_pan.js
Log:
merged mod_pan
Modified: trunk/mapbender/http/javascripts/mod_pan.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_pan.js 2011-09-07 07:10:05 UTC (rev 8107)
+++ trunk/mapbender/http/javascripts/mod_pan.js 2011-09-07 07:29:10 UTC (rev 8108)
@@ -32,7 +32,48 @@
var mb_panActive = false;
var startPos, stopPos;
var map = Mapbender.modules[options.target];
-
+
+
+ var mousedown = function (e) {
+ mb_panActive = true;
+ startPos = map.getMousePosition(e);
+ stopPos = new Point(startPos);
+ return false;
+ };
+
+ var mousemove = function (e) {
+ if (!mb_panActive) {
+ return false;
+ }
+ stopPos = map.getMousePosition(e);
+ var dif = stopPos.minus(startPos);
+ map.moveMap(dif.x, dif.y);
+ if (!$.browser.msie){
+ return true;
+ }
+ return false;
+ };
+
+ var mouseup = function (e) {
+ if (!mb_panActive) {
+ return false;
+ }
+ if (!map) {
+ return false;
+ }
+ mb_panActive = false;
+ var dif = stopPos.minus(startPos);
+ var widthHeight = new Mapbender.Point(
+ map.getWidth(),
+ map.getHeight()
+ );
+ var center = widthHeight.times(0.5).minus(dif);
+ var realCenter = map.convertPixelToReal(center);
+ map.moveMap();
+ map.zoom(false, 1.0, realCenter);
+ return false;
+ };
+
var button = new Mapbender.Button({
domElement: that,
over: options.src.replace(/_off/, "_over"),
@@ -47,41 +88,9 @@
}
$(map.getDomElement())
.css("cursor", "move")
- .mousedown(function (e) {
- mb_panActive = true;
- startPos = map.getMousePosition(e);
- stopPos = new Point(startPos);
- return false;
- }).mousemove(function (e) {
- if (!mb_panActive) {
- return false;
- }
- stopPos = map.getMousePosition(e);
- var dif = stopPos.minus(startPos);
- map.moveMap(dif.x, dif.y);
- if (!$.browser.msie){
- return true;
- }
- return false;
- }).mouseup(function (e) {
- if (!mb_panActive) {
- return false;
- }
- if (!map) {
- return false;
- }
- mb_panActive = false;
- var dif = stopPos.minus(startPos);
- var widthHeight = new Mapbender.Point(
- map.getWidth(),
- map.getHeight()
- );
- var center = widthHeight.times(0.5).minus(dif);
- var realCenter = map.convertPixelToReal(center);
- map.moveMap();
- map.zoom(false, 1.0, realCenter);
- return false;
- });
+ .mousedown(mousedown)
+ .mousemove(mousemove)
+ .mouseup(mouseup);
},
stop: function () {
if (!map) {
@@ -89,9 +98,9 @@
}
$(map.getDomElement())
.css("cursor", "default")
- .unbind("mousedown")
- .unbind("mouseup")
- .unbind("mousemove");
+ .unbind("mousedown", mousedown)
+ .unbind("mouseup", mouseup)
+ .unbind("mousemove", mousemove);
mb_panActive = false;
}
});
More information about the Mapbender_commits
mailing list