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

Jose Manuel C G gis at mapas-sll.com
Tue Apr 3 11:51:24 EDT 2007


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.



More information about the mapguide-users mailing list