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

Reply via email to