Solution...
In MouseDefaults.js, change the behaviour of defaultWheelUp and
defaultWheelDown so that they behave like the incremental zoom clicks on
the zoombar. Comment out the old (original) behaviour, and replace it
with map.zoomIn and map.zoomOut, like this:
/** User spun scroll wheel up
*
*/
defaultWheelUp: function(evt) {
//if (this.map.getZoom() <= this.map.getNumZoomLevels()) {
// this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),
// this.map.getZoom() + 1);
//}
this.map.zoomIn();
},
/** User spun scroll wheel down
*
*/
defaultWheelDown: function(evt) {
//if (this.map.getZoom() > 0) {
// this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),
// this.map.getZoom() - 1);
//}
this.map.zoomOut();
},
Regards,
Mike Quentel
-----Original Message-----
From: Michael Quentel
Sent: Tuesday, 23 October 2007 11:42
To: [email protected]
Subject: wheel zooming: want to turn off re-centre of map at mouse
location
In Navigation.js, it appears that the wheelChange function gets the
event x y, and not only zooms in or out, but also appears to re-centre
on the mouse event location. Is this correct? Please, need advice: I'd
like to turn off the map re-centreing on the mouse location when doing
mouse wheel zoom. Not having success changing this. Is Navigation.js
even where I should be trying to change this functionality?
wheelChange function as it is now:
wheelChange: function(evt, deltaZ) {
var newZoom = this.map.getZoom() + deltaZ;
if (!this.map.isValidZoomLevel(newZoom)) return;
var size = this.map.getSize();
var deltaX = size.w/2 - evt.xy.x;
var deltaY = evt.xy.y - size.h/2;
var newRes = this.map.baseLayer.resolutions[newZoom];
var zoomPoint = this.map.getLonLatFromPixel(evt.xy);
var newCenter = new OpenLayers.LonLat(
zoomPoint.lon + deltaX * newRes,
zoomPoint.lat + deltaY * newRes );
this.map.setCenter( newCenter, newZoom );
},
I tried to change the above to read the following:
wheelChange: function(evt, deltaZ) {
var newZoom = this.map.getZoom() + deltaZ;
if (!this.map.isValidZoomLevel(newZoom)) return;
//var size = this.map.getSize();
//var deltaX = size.w/2 - evt.xy.x;
//var deltaY = evt.xy.y - size.h/2;
var newRes = this.map.baseLayer.resolutions[newZoom];
//var zoomPoint = this.map.getLonLatFromPixel(evt.xy);
var zoomPoint = this.map.getCenter();
//var newCenter = new OpenLayers.LonLat(
// zoomPoint.lon + deltaX * newRes,
// zoomPoint.lat + deltaY * newRes );
var newCenter = zoomPoint;
this.map.setCenter( newCenter, newZoom );
},
That failed. I also tried the following, which also failed:
wheelChange: function(evt, deltaZ) {
var newZoom = this.map.getZoom() + deltaZ;
if (!this.map.isValidZoomLevel(newZoom)) return;
var size = this.map.getSize();
//var deltaX = size.w/2 - evt.xy.x;
//var deltaY = evt.xy.y - size.h/2;
var deltaX = 1;
var deltaY = 1;
var newRes = this.map.baseLayer.resolutions[newZoom];
//var zoomPoint = this.map.getLonLatFromPixel(evt.xy);
var zoomPoint = this.map.getCenter();
//debug
console.info("zoomPoint.lat: ", zoomPoint.lat);
console.info("zoomPoint.lon: ", zoomPoint.lon);
var newCenter = new OpenLayers.LonLat(
zoomPoint.lon + deltaX * newRes,
zoomPoint.lat + deltaY * newRes );
this.map.setCenter( newCenter, newZoom );
},
The Firebug console.info calls did not even appear. I'm not getting the
result I expected. What would work?
Thank you.
Cheers,
Mike Quentel
---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential
information, privileged material (including material protected by the
solicitor-client or other applicable privileges), or constitute non-public
information. Any use of this information by anyone other than the intended
recipient is prohibited. If you have received this transmission in error,
please immediately reply to the sender and delete this information from your
system. Use, dissemination, distribution, or reproduction of this transmission
by unintended recipients is not authorized and may be unlawful.
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users