[Mapbender-commits] r3678 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Mar 12 12:10:24 EDT 2009
Author: christoph
Date: 2009-03-12 12:10:23 -0400 (Thu, 12 Mar 2009)
New Revision: 3678
Modified:
trunk/mapbender/http/javascripts/map_obj.js
trunk/mapbender/http/javascripts/mapnf.php
Log:
http://trac.osgeo.org/mapbender/ticket/319
Modified: trunk/mapbender/http/javascripts/map_obj.js
===================================================================
--- trunk/mapbender/http/javascripts/map_obj.js 2009-03-12 16:09:23 UTC (rev 3677)
+++ trunk/mapbender/http/javascripts/map_obj.js 2009-03-12 16:10:23 UTC (rev 3678)
@@ -78,8 +78,14 @@
var clickX, clickY;
if ($.browser.msie) {
- clickX = e.clientX;
- clickY = e.clientY;
+ if (window.event) {
+ clickX = window.event.clientX;
+ clickY = window.event.clientY;
+ }
+ else {
+ clickX = e.clientX;
+ clickY = e.clientY;
+ }
}
else{
clickX = e.pageX;
Modified: trunk/mapbender/http/javascripts/mapnf.php
===================================================================
--- trunk/mapbender/http/javascripts/mapnf.php 2009-03-12 16:09:23 UTC (rev 3677)
+++ trunk/mapbender/http/javascripts/mapnf.php 2009-03-12 16:10:23 UTC (rev 3678)
@@ -19,4 +19,67 @@
require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
?>
-mb_registerMapObj('', 'mapframe1', null,<?php echo $e_width; ?>, <?php echo $e_height; ?>);
\ No newline at end of file
+
+(function () {
+
+ var mapTimeout;
+ var sum_delta = 0;
+ var lastTimestamp;
+ var lastScrollPosition;
+ var mapObject;
+
+
+
+ eventInitMap.register(function init_mod_map1(){
+
+ mapObject = mb_registerMapObj('', 'mapframe1', null,<?php echo $e_width; ?>, <?php echo $e_height; ?>);
+
+ $(document).mousewheel(function (e, delta) {
+ if (sum_delta == 0) {
+ mapTimeout = setTimeout(function () {
+ lastScrollPosition = mapObject.getMousePosition(e);
+ mousewheelZoom();
+ },
+ 100);
+ }
+ sum_delta = sum_delta + (delta);
+ var currentTime = new Date();
+ lastTimestamp = currentTime.getTime();
+
+ return false;
+ });
+ });
+
+ function mousewheelZoom () {
+ var currentTime = new Date();
+
+ if (currentTime.getTime() - lastTimestamp > 200) {
+ if (lastScrollPosition !== null) {
+ var pos = mapObject.convertPixelToReal(lastScrollPosition);
+
+ if (sum_delta > 0) {
+ mapObject.zoom(true, Math.pow(Mapbender.zoomMousewheel, sum_delta), pos.x, pos.y);
+ }
+ else {
+ mapObject.zoom(false, Math.pow(Mapbender.zoomMousewheel, -sum_delta), pos.x, pos.y);
+ }
+
+ var newPos = new Point();
+ newPos.x = mapObject.width - lastScrollPosition.x;
+ newPos.y = mapObject.height - lastScrollPosition.y;
+
+ var posAfterZoom = mapObject.convertPixelToReal(newPos);
+ mapObject.zoom(false, 1.0, posAfterZoom.x, posAfterZoom.y);
+ }
+ sum_delta = 0;
+ clearTimeout(mapTimeout);
+ }
+ else {
+ mapTimeout = setTimeout(function () {
+ mousewheelZoom(sum_delta);
+ },
+ 100
+ );
+ }
+ }
+})();
\ No newline at end of file
More information about the Mapbender_commits
mailing list