[mapguide-users] patch for Mouse Wheel Zoom, set scale andimage on loading map in Ajax.

Chris Claydon chris.claydon at autodesk.com
Tue Apr 3 16:57:34 EDT 2007


Hi Jose,

Thank you for sending in your code. I'm in the process of adding your
enhancements to the AJAX viewer.

I thought of a couple of further enhancements to the mouse wheel
handling, and I'd like to know what you think...

1) I'd like to re-draw the current map image dynamically as the user
scrolls the wheel, the same way that the map is re-drawn when the user
moves the zoom slider control.

2) Rather than re-centering the map at the location of the cursor, I'd
like to zoom in such a way that the real-world point at the cursor
remains the same. This is how the mouse wheel zoom currently works in
the DWF viewer.

I look forward to your comments.

Sincerely,

Chris Claydon.

-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Jose Manuel
C G
Sent: April 3, 2007 9:51 AM
To: mapguide-users at lists.osgeo.org
Subject: Re: [mapguide-users] patch for Mouse Wheel Zoom, set scale
andimage on loading map in Ajax.


Sorry. Here the rest of the code:

1) Mouse Wheel:

In Ajaxmappane.templ:

...
//Added by J M Cerrejon
function handle(delta,event) {
var isIE = document.all;
var x = isIE ? event.clientX - mapPosX : event.screenX - mapPosX;
var y = isIE ? event.clientY : event.screenY;

if (delta < 0)
	ZoomOut(x, y); // You can put here your function
else
	ZoomIn(x, y);
}

function wheel(event){
var delta = 0;
if (!event) event = window.event;
if (event.wheelDelta) {
delta = event.wheelDelta/120;
if (window.opera) delta = -delta;
} else if (event.detail) {
delta = -event.detail/3;
}
if (delta)
handle(delta,event);
}

if (window.addEventListener)
window.addEventListener('DOMMouseScroll', wheel, false);
window.onmousewheel = document.onmousewheel = wheel;
// End code
...
<script>
</head>
<body...

2) Input box to the scale (statusbar.templ):
...
//Added by J M Cerrejon
var tempValue;

function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}
function keyboardcontroller(val) {
  var strPass = val.value;
  var strLength = strPass.length;
  var lchar = val.value.charAt((strLength) - 1);
  var cCode = CalcKeyCode(lchar);

  if (cCode < 48 || cCode > 57 ) {
    var myNumber = val.value.substring(0, (strLength) - 1);
    val.value = myNumber;
  }
  return false;
}
function setZoomToScale(val) {
	if (val.value == "") {
		val.value = tempValue;
		return;
	}else{
	
top.ViewerFrame.mapFrame.ZoomToScale(parseInt(val.value));
		val.value="1: " + val.value;
		document.getElementById(4).focus();
	}
}
// End code
...
</script>
  </head>
  <body ...
...        <input class="StatusField" id="2" type="text" readonly >...
        <input class="StatusField" id="3" name="3" type="text"
onKeyUp="keyboardcontroller(this);" onKeyDown="if(event.keyCode==13)
document.getElementById(4).focus();" onfocus="this.style.backgroundColor
=
'lightyellow';tempValue = this.value; this.value='';"
onblur="this.style.backgroundColor = '#f0f0f0'; setZoomToScale(this);"
onclick="this.focus();">

<input class="StatusField" id="4" type="text" readonly >
...

-- 
View this message in context:
http://www.nabble.com/patch-for-Mouse-Wheel-Zoom%2C-set-scale-and-image-
on-loading-map-in-Ajax.-tf3491633s16610.html#a9816211
Sent from the MapGuide Users mailing list archive at Nabble.com.

_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users



More information about the mapguide-users mailing list