• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Autodesk MapGuide Enterprise

    Reply
    Contributor
    Posts: 14
    Registered: ‎10-18-2007

    Using Wheel Button to Pan

    1055 Views, 9 Replies
    11-13-2007 11:06 AM
    How would I go about making it so that clicking the middle/wheel button on the mouse will enable the pan tool while the button is held down. (Like in AutoCAD, Map3D etc.)

    Thanks,

    -Mike
    Please use plain text.
    Distinguished Contributor
    Posts: 105
    Registered: ‎05-21-2006

    Re: Using Wheel Button to Pan

    11-14-2007 03:16 PM in reply to: mistermike
    Look for the OnMouseDown(e) and OnMouseUp(e) functions in ajaxmappane.templ

    That's where all the action starts and ends.

    - Jackie
    http://themapguyde.blogspot.com
    http://au.linkedin.com/in/jackieng
    Please use plain text.
    Contributor
    Posts: 14
    Registered: ‎10-18-2007

    Re: Using Wheel Button to Pan

    11-15-2007 08:16 AM in reply to: mistermike
    Thanks for the reply.
    I found the OnMouseDown(e) and OnMouseUp(e) functions in ajaxmappane.templ, I'm just not sure what to do with them. :smileyhappy: I'm still kind of new at this.

    My Autodesk reseller is telling me it can't be done in the AJAX viewer (which is what I'm using, forgot to mention that). Does she know what she's talking about?

    Thanks again,

    -Mike
    Please use plain text.
    Distinguished Contributor
    Posts: 105
    Registered: ‎05-21-2006

    Re: Using Wheel Button to Pan

    11-18-2007 05:08 PM in reply to: mistermike
    I can't see why it could not be done.

    You are basically reusing the pan behaviour which is already implemented in the AJAX viewer, you just now have to hook that behaviour to a middle mouse click and release.

    Unfortuantely, I cannot show you how to implement it, because I haven't done it myself, but I do have a high-level knowledge of the internals of the AJAX viewer to tell you that such a thing is possible.

    Also, resellers usually aren't programmers and/or technically minded ;-)
    http://themapguyde.blogspot.com
    http://au.linkedin.com/in/jackieng
    Please use plain text.
    *James Murphy

    Re: Using Wheel Button to Pan

    11-19-2007 01:04 PM in reply to: mistermike
    wrote in ...



    Jackie, you are starting to sound like Andrew D.
    : )

    We are trying.

    --

    Murph
    The world is not FLAT so why is your GIS data?
    http://map3d.wordpress.com
    Please use plain text.
    Active Member
    Posts: 6
    Registered: ‎06-19-2003

    Re: Using Wheel Button to Pan

    04-17-2008 07:51 AM in reply to: mistermike
    in the mousedown event, you have to check to see if it's the middle mouse button (these are different values for IE and FF...just google and you'll find this easy enough) then call the start pan function and on the mouseup, call the end pan function.
    Please use plain text.
    Member
    Posts: 5
    Registered: ‎08-04-2008

    Re: Using Wheel Button to Pan

    10-01-2012 09:23 PM in reply to: mistermike

    Hi all.  Was wondering if anyone had done this change successfully?  I'd really love to enable panning with mouse wheel.

     

    many thanks

    Please use plain text.
    Valued Contributor
    Posts: 64
    Registered: ‎12-18-2003

    Re: Using Wheel Button to Pan

    12-03-2012 11:20 AM in reply to: david.roy

    Would also like to know the solution

     

    thanks,

    Please use plain text.
    New Member
    Posts: 2
    Registered: ‎03-20-2013

    Re: Using Wheel Button to Pan

    03-20-2013 09:00 AM in reply to: mitchellhastings1484

    Hello,

     

    Firstly, Thanks Jackie for telling everyone where to look, this was pretty easy, and I'm not great at Javascript

     

    I tackled this, and here is what I've got working...

    Looks like the placement is everything to make sure you check for middle before left/ right

     

    In ajamappane.templ....

     

    in OnMouseDown(e) before the check for Left Button Click, check for Middle Mouse

    function OnMouseDown(e)
    {
        if(!PopupMouseDown(e))
        {
            hidePopup(tbMenu);
            hidePopup(ctxMenu);
            hidePopup(infoMenu);
            parent.ForwardMouseDown(document, e);
        }
        else
            return false;
    
        if(!mapInit)
            return false;
            
    // NEW CODE BLOCK START HERE
        if(e.which && e.which == 2) //2 is middle button in W3C/Netscape Which
    	StartPanning(e);
        else if(e.button && e.button == 4) //for ie, middle button is 4
            StartPanning(e);
    // END CODE BLOCK HERE FOR MIDDLE Mouse PANNING
    		
         if(e.which && e.which != 1)
            return true;
        else if(e.button && e.button != 1)//for ie
            return true;

     

     

     

    Then in OnMouseUp(e)

     

    function OnMouseUp(e)
    {       
        var x = e.clientX - mapPosX;
        var y = e.clientY;
        try
        {
            e.stopPropagation();
        }
        catch(ex)
        {
            e.cancelBubble = true;
        }
    
    // NEW CODE ADDED HERE, BEFORE DIGITIZATION CHECK
    if(e.which && e.which == 2) //2 is middle button EndPanning(e); else if(e.button && e.button == 4)//for ie EndPanning(e); // END NEW CODE
    if(digitizing) { digitizer.MouseUp(e, x, y); return false; } if(isAlertShow) return;

    I didn't test it out with other redlining or digitizing continuous commands.. ie pan will digitizing, but for my needs, just panning with the middle button adds a tonne of user experience if other things break.

     

     

    Please use plain text.
    Member
    Posts: 5
    Registered: ‎08-04-2008

    Re: Using Wheel Button to Pan

    03-20-2013 08:44 PM in reply to: mistermike

    Perfect!  does the trick, thankyou for posting.

    Please use plain text.