News:

Build a stunning handcrafted website with IT Acumens

Main Menu

Listing 1: Basic Page (Events.html)

Started by thiruvasagamani, Jan 23, 2009, 04:20 PM

Previous topic - Next topic

thiruvasagamani

Listing 1: Basic Page (Events.html)

If you load this page in a browser, you should see a map of the United States with the basic Virtual Earth navigation dashboard.
Working with Events

Working with a Virtual Earth event can be divided into a two step process:

   1. Create a callback method to respond to the event. The callback method should be a JavaScript function that expects a single argument and optionally returns a Boolean value. The argument will contain information related to the event, and the return value is an indicator of whether your callback completely processed the event. If your callback completely handles the event, and you do not want any further processing, return true. If you want to allow the default event action to continue (e.g. double click to zoom in), then return false.
   2. Register the event with your map control using the map.AttachEvent(eventname, functionname) method.

When your selected event occurs, the map will automatically execute your callback function. The event object that is passed to your function contains a set of properties that are event specific.

Using these basic guidelines, you can group the various available events into three categories:

    * Map events – Map events relate to basic map navigation tasks such as zooming, panning and changing the view. You will work with these events most often.
    * Mouse events – Mouse events relate to mouse driven input such as left click, right click, mouseover, and so on. You will use these events to control the way your users interact with the map. You want to carefully consider your mouse events as most mouse actions are already mapped to standard navigation mechanics (e.g. mouse scroll wheel maps to zoom in/zoom out).
    * Keyboard events – Keyboard events are the complement to mouse events, but relate to keyboard input. Once again, some keys are already mapped to standard navigation (e.g. arrows map to pan functions) so you want to carefully consider modifying this functionality.

Each of these event types is examined in greater detail below. In addition, the last section of this article describes how to override the default Virtual Earth events.


Source : MSDN
Thiruvasakamani Karnan