The Map control can raise both server and client events. Server events occur after client events and are handled in server-side code that you write for the Web page. Client events are handled in client script, typically ECMAScript (JavaScript), and are raised before server events. The server-side events are triggered even if client-side events are not present.
|
Event
|
Designation: Server or Client
|
Description
|
| OnClientChangeMapStyle | Client | Raised when the map style is changed |
| OnClientChangeView | Client | Raised when the map view is changed |
| OnClientEndPan | Client | Raised when a pan of the map ends |
| OnClientEndZoom | Client | Raised when a zoom of the map ends |
| OnClientFind | Client | Raised when a particular result is selected from multiple results in the Disambiguation dialog |
| OnClientGetDirections | Client | Raised when the route is rendered on the map |
| OnClientLoadMap | Client | Raised when the map is loaded |
| OnClientModeNotAvailable | Client | Raised when the map mode fails to change to 3D mode |
| OnClientObliqueChange | Client | Raised when the when the bird's eye image is changed, such as when the map is displaying a bird's eye image and that image is changed |
| OnClientObliqueEnter | Client | Raised when bird's eye images are available at the center of the current map |
| OnClientObliqueLeave | Client | Raised when bird's eye images are no longer available at the center of the current map |
Handling Client Events
Client events are handled as JavaScript functions that are declared within a <script> tag. All JavaScript event handling functions must have the same signature, where OnClientEventHandler is the name of the JavaScript function that handles the event.
JavaScript Syntax
function OnClientEventHandler (sender, args)
Parameters
|
Parameter
|
Description
|
| sender | The DOM element raising the event. |
| args | The event arguments object. This object has the methods get_cancel and set_cancel. |
Remarks
Use the set_cancel method to cancel the execution of the associated server event.
Handling Server Events
Server events are handled as C# methods within the main class. All but one C# event handling method must have the same signature, where OnServerEventHandler is the name of the C# method that handles the event.
The exception is the handler for the OnServerChangeMapStyle event, which takes a MapEventArgs object for the second argument.
C# Syntax
protected void OnServerEventHandler(object sender, EventArgs e)
Parameters
|
Parameter
|
Description
|
| Sender | The Map control object. |
| e | The event arguments object. |
Remarks
Server-side event handlers often use classes, such as the MapEventArgs class, from the Microsoft.Live.ServerControls.VE namespace. Therefore, the file in which these event handlers are defined should contain the following using statement:
using Microsoft.Live.ServerControls.VE;