[OpenLayers-Users] mousewheel: center on point or not?
Bart van den Eijnden (OSGIS)
bartvde at osgis.nl
Tue Mar 18 10:25:54 EDT 2008
Hi list,
I thought the mousewheel used to center on the mouse cursor, but it does not
do this anymore in trunk. Or maybe my mind is playing tricks on me :-)
Questions:
-is this intentional?
-if so, could it not become a property of the Navigation Control so people
can control this behaviour themselves?
I commented the following in Navigation.js (deltaX * newRes etc.) to get it
to zoom centered on the mouse position again:
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.getResolutionForZoom(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 );
},
Best regards,
Bart
--
Bart van den Eijnden
OSGIS, Open Source GIS
http://www.osgis.nl
More information about the Users
mailing list