MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Virtual Earth API: Customizing Mouse Wheel Zoom

This is a discussion on Virtual Earth API: Customizing Mouse Wheel Zoom within the Virtual Earth Blogs 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 ...


Go Back   MapPoint Forums > Blogs > Virtual Earth Blogs

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 01-04-2008
Junior Member
Yellow Belt
 
Join Date: Jan 2008
Posts: 25
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...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/virtual-earth-api-customizing-mouse-wheel-zoom-6962.html

Posted By For Type Date
Merging Multiple Routes - MapPoint Articles - MP2K Magazine This thread Refback 01-08-2008 03:05 PM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Virtual Earth News from GEOINT 2007: Virtual Earth Appliance VE For Government Virtual Earth Blogs 0 10-24-2007 12:10 PM
How To: Skipping Zoom Levels in Virtual Earth VirtualEarth MSDN Blog Virtual Earth Blogs 0 09-15-2007 02:17 PM
Virtual Earth @ WPC VirtualEarth MSDN Blog Virtual Earth Blogs 0 09-15-2007 02:17 PM
MSN Virtual Earth. Eric Frost News and Announcements 0 11-03-2006 11:27 AM
Capturing Mouse Wheel Event Anonymous MapPoint Web Service and Virtual Earth 2 11-30-2005 07:31 AM


All times are GMT -5. The time now is 05:33 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map

Andorra Ski Holidays
Andorra ski holidays offer tax-free shopping and a range of great après-ski activities when you have finished on the slopes. Book online today.

City Breaks
Top 10 City Breaks . Based on holidays booked this year, these are the most popular City Breaks for 2006

Holidays Italy
Book your holidays in Italy. Italy has a great climate and the beaches to go with it. Book a great deal for great value online at dealchecker.co.uk.

Antigua Holidays
We have the most popular Antigua holidays at highly competitive prices at The Holiday Place. Book a break in sunny Antigua today.

Cheap Morocco Holidays
Cheap Morocco holidays may be the answer to your cheap holiday search. With sunshine throughout most of the year it can be great value if you avoid the peak season. Why not include a trip to the small tranquil town of Chefchaouen Tangier in your visit?

Compare holiday prices
Compare holiday prices online where you can see all the possibilities at Travel.co.uk

Florida Holidays
Take a sunny holiday break! Find info on Florida holidays at On The Beach!


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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51