Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 3 of 3

Virtual Earth API: Customizing Mouse Wheel Zoom

This is a discussion on Virtual Earth API: Customizing Mouse Wheel Zoom within the Bing Maps Blogs & Tweets forums, part of the Blogs category; The Virtual Earth map control supports several interactive ways to zoom in and out on the 2D map view.  For ...

  1. #1
    Keith Kinnan's Weblog is offline Member Green Belt
    Join Date
    Jan 2008
    Posts
    65

    Virtual Earth API: Customizing Mouse Wheel Zoom

    The Virtual Earth map control supports several interactive ways to zoom in and out on the 2D map view.  For example, you can:

    • Click on (or click and hold) the zoom In/zoom Out icons on the navigation control.
    • Double-click on the map to zoom in at a particular point.
    • Hold down the "Alt" key and then click and drag on the mouse to create a zoom box which will become the next view.
    • Use the mouse wheel to zoom in and zoom out.

    By default, when scrolling the mouse wheel up, it will zoom in on the center of the current view.  When scrolling the mouse wheel down, it will zoom out with the center of the view the center of the scene.

    The Virtual Earth v5 and v6 API allow you to override many of the Virtual Earth events with the VEMap.AttachEvent call including many mouse events such as "onclick", "ondoubleclick", "onmousemove", "onmousedown", and "onmousewheel".  Your event handler can override the default Virtual Earth behavior by returning true from the handler.  If you return false from your event handler, your custom behavior and the default behavior will be executed.  For example, the following code snippet shows how to override "onmousedown" and "onmousewheel" for 2D in v6:

    function EventMouseDown()
    {
       //insert custom behavior here...
       //return true to disable the default behavior. return false to enable the default behavior.
       return true;
    }


    function EventMouseWheel()
    {
       //insert custom behavior here...
       //return true to disable the default behavior. return false to enable the default behavior.
       return true;
    }

    map.AttachEvent("onmousedown", EventMouseDown);
    map.AttachEvent("onmousewheel", EventMouseWheel);

    Here's a link to a working example with checkboxes allowing you to turn off mouse down and mouse wheel events in 2D:

    Virtual Earth API Event Customization Sample

    The v6 also API added a simpler built-in approach to overriding the default mouse wheel zoom behavior. The default zoom in behavior for the mouse wheel is to zoom to the center of the map view. However, some users want the mouse wheel to zoom to the mouse cursor in the view.  To make this simple so you do not have to override "onmousewheel", we went ahead and added the SetMouseWheelZoomToCenter call to VEMap.  By default it is set to true so mouse wheel events will zoom to the center of the scene.  However, if you pass false to this function, the mouse wheel will zoom to the mouse cursor.

    Here's a link to a working example with radio buttons allowing you to select mouse wheel "Zoom to Center" or "Zoom to Mouse" behavior in 2D:

    Virtual Earth Mouse Wheel Zoom Sample



    More...

  2. #2
    Domine is offline Junior Member White Belt
    Join Date
    Jul 2009
    Posts
    1

    Re: Virtual Earth API: Customizing Mouse Wheel Zoom

    Hi!

    Please can you help me? I have problem with my veMap. I want to disable the mouse wheel zoom (And that's already done) BUT I still want to enable the "scrolling down the page" when hovering the map!

    How to fix this?? If I'm scrolling down the page by now, and reach the map, the scrolling stops...

    Hope someone can help me with this!

    // Domine

  3. #3
    cx35 is offline Junior Member White Belt
    Join Date
    Jul 2009
    Posts
    1

    Re: Virtual Earth API: Customizing Mouse Wheel Zoom


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Virtual Earth News from GEOINT 2007: Virtual Earth Appliance
    By VE For Government in forum Bing Maps Blogs & Tweets
    Replies: 0
    Last Post: 10-24-2007, 01:10 PM
  2. How To: Skipping Zoom Levels in Virtual Earth
    By VirtualEarth MSDN Blog in forum Bing Maps Blogs & Tweets
    Replies: 0
    Last Post: 09-15-2007, 03:17 PM
  3. Virtual Earth @ WPC
    By VirtualEarth MSDN Blog in forum Bing Maps Blogs & Tweets
    Replies: 0
    Last Post: 09-15-2007, 03:17 PM
  4. MSN Virtual Earth.
    By Eric Frost in forum News and Announcements
    Replies: 0
    Last Post: 11-03-2006, 12:27 PM
  5. Capturing Mouse Wheel Event
    By Anonymous in forum Bing Maps and MapPoint Web Service
    Replies: 2
    Last Post: 11-30-2005, 08:31 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27