[Mapbender-commits] r4723 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Sat Sep 26 11:34:52 EDT 2009
Author: christoph
Date: 2009-09-26 11:34:51 -0400 (Sat, 26 Sep 2009)
New Revision: 4723
Added:
trunk/mapbender/http/javascripts/mod_pan.js
Removed:
trunk/mapbender/http/javascripts/mod_pan.php
Log:
Added: trunk/mapbender/http/javascripts/mod_pan.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_pan.js (rev 0)
+++ trunk/mapbender/http/javascripts/mod_pan.js 2009-09-26 15:34:51 UTC (rev 4723)
@@ -0,0 +1,106 @@
+/**
+ * Package: selArea
+ *
+ * Description:
+ * Zoom by rectangle
+ *
+ * Files:
+ * - http/javascripts/mod_selArea.js
+ *
+ * SQL:
+ * > <SQL for element>
+ * >
+ * > <SQL for element var>
+ *
+ * Help:
+ * http://www.mapbender.org/SelArea1
+ *
+ * Maintainer:
+ * http://www.mapbender.org/User:Christoph_Baudson
+ *
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License
+ * and Simplified BSD license.
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
+ */
+
+var that = this;
+
+Mapbender.events.init.register(function () {
+
+ var mb_panActive = false;
+ var startPos, stopPos;
+ var map = Mapbender.modules[options.target];
+
+ var button = new Mapbender.Button({
+ domElement: that,
+ over: options.src.replace(/_off/, "_over"),
+ on: options.src.replace(/_off/, "_on"),
+ off: options.src,
+ name: options.id,
+ go: function () {
+ if (!map) {
+ new Mb_exception(options.id + ": " +
+ options.target + " is not a map!");
+ return;
+ }
+ $(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);
+
+ mb_arrangeElement(map.frameName, options.target+"_maps", dif.x, dif.y);
+
+ for(var i = 0; i < mb_PanSubElements.length; i++) {
+ mb_arrangeElement(map.frameName, mb_PanSubElements[i], 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);
+
+ mb_arrangeElement(map.frameName, options.target + "_maps", 0, 0);
+ for (var i = 0; i < mb_PanSubElements.length; i++) {
+ mb_arrangeElement(map.frameName, mb_PanSubElements[i], 0, 0);
+ }
+ map.zoom(false, 1.0, realCenter);
+ return false;
+ });
+ },
+ stop: function () {
+ if (!map) {
+ return false;
+ }
+ $(map.getDomElement())
+ .css("cursor", "pointer")
+ .unbind("mousedown")
+ .unbind("mouseup")
+ .unbind("mousemove");
+ mb_panActive = false;
+ }
+ });
+});
Deleted: trunk/mapbender/http/javascripts/mod_pan.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_pan.php 2009-09-26 15:33:14 UTC (rev 4722)
+++ trunk/mapbender/http/javascripts/mod_pan.php 2009-09-26 15:34:51 UTC (rev 4723)
@@ -1,116 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/mod_pan.php
-# Copyright (C) 2002 CCGIS
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-echo "var mod_pan_target = '".$e_target[0]."';";
-?>
-var mod_pan_elName = "<?php echo $e_id; ?>";
-var mod_pan_frameName = "";
-var mod_pan_MapObj = null;
-
-var mod_pan_img_on = new Image(); mod_pan_img_on.src = "<?php echo preg_replace("/_off/","_on",$e_src); ?>";
-var mod_pan_img_off = new Image(); mod_pan_img_off.src = "<?php echo $e_src; ?>";
-var mod_pan_img_over = new Image(); mod_pan_img_over.src = "<?php echo preg_replace("/_off/","_over",$e_src); ?>";
-
-
-var mb_panActive = false;
-
-eventInit.register(function () {
- mb_regButton(function (ind){
- mod_pan_MapObj = getMapObjByName(mod_pan_target);
- mb_button[ind] = document.getElementById(mod_pan_elName);
- mb_button[ind].img_over = mod_pan_img_over.src;
- mb_button[ind].img_on = mod_pan_img_on.src;
- mb_button[ind].img_off = mod_pan_img_off.src;
- mb_button[ind].status = 0;
- mb_button[ind].elName = mod_pan_elName;
- mb_button[ind].fName = mod_pan_frameName;
- mb_button[ind].go = function () {
- var p = mod_pan_MapObj.getDomElement();
- p.style.cursor = "move";
-
- p.onmousedown = mod_pan_start;
- p.onmouseup = mod_pan_stop;
- p.onmousemove = mod_pan_run;
- };
- mb_button[ind].stop = function () {
- var p = mod_pan_MapObj.getDomElement();
- p.style.cursor = "pointer";
-
- p.onmousedown = null;
- p.onmouseup = null;
- p.onmousemove = null;
- };
- });
-});
-
-function mod_pan_start(e){
- mb_panActive = true;
- var pos = mod_pan_MapObj.getMousePosition(e);
- var el = mod_pan_MapObj.getDomElement();
- mb_start_x=pos.x;
- mb_start_y=pos.y;
- mb_end_x = pos.x;
- mb_end_y = pos.y;
- return false;
-}
-function mod_pan_run(e){
- if(mb_panActive){
- var pos = mod_pan_MapObj.getMousePosition(e);
- mb_end_x = pos.x;
- mb_end_y = pos.y;
- mod_pan_move_map();
- if(ie){
- return false;
- }
- else{
- return true;
- }
- }
-}
-function mod_pan_stop(e){
- if(mb_panActive){
- mb_panActive = false;
- var dif_x = mb_end_x - mb_start_x;
- var dif_y = mb_end_y - mb_start_y;
- var width = mod_pan_MapObj.width;
- var height = mod_pan_MapObj.height;
-
- var el = mod_pan_MapObj.getDomElement();
- var center_x = (width / 2) - dif_x;
- var center_y = (height / 2) - dif_y;
- var real_center = makeClickPos2RealWorldPos(mod_pan_target,center_x, center_y);
-
- mb_arrangeElement(mod_pan_MapObj.frameName, mod_pan_target+"_maps", 0, 0);
- for(var i=0; i<mb_PanSubElements.length; i++){
- mb_arrangeElement(mod_pan_MapObj.frameName, mb_PanSubElements[i], 0, 0);
- }
- zoom(mod_pan_target,false, 1.0, real_center[0], real_center[1]);
- }
-}
-function mod_pan_move_map(){
- var dif_x = mb_end_x - mb_start_x;
- var dif_y = mb_end_y - mb_start_y;
-
- mb_arrangeElement(mod_pan_MapObj.frameName, mod_pan_target+"_maps", dif_x, dif_y);
- for(var i=0; i<mb_PanSubElements.length; i++){
- mb_arrangeElement(mod_pan_MapObj.frameName, mb_PanSubElements[i], dif_x, dif_y);
- }
- return false;
-}
More information about the Mapbender_commits
mailing list