Map Class
Represents a map.
Constructor
| Name | Definition | Description |
|---|---|---|
|
Map |
|
Initializes a new instance of the Map class. |
Properties
| Name | Type | Description |
|---|---|---|
|
entities |
The map’s entities. Use this property to add or remove entities from the map. |
Static Methods
| Name | Definition | Return Value | Description |
|---|---|---|---|
|
getVersion |
|
string |
Returns the version of the map control. |
Methods
| Name | Definition | Return Value | Description |
|---|---|---|---|
|
blur |
|
None |
Removes focus from the map control so that it does not respond to keyboard events. |
|
dispose |
|
None |
Deletes the Map object and releases any associated resources. |
|
focus |
|
None |
Applies focus to the map control so that it responds to keyboard events. |
|
getBounds |
|
Returns the location rectangle that defines the boundaries of the current map view. |
|
|
getCenter |
|
Returns the location of the center of the current map view. |
|
|
getCopyrights |
|
string[] |
Returns to the specified callback an array of strings representing the attributions of the imagery currently displayed on the map. |
|
getCredentials |
|
None |
Gets the session ID. This method calls the callback function with the session ID as the first parameter.
|
|
getHeading |
|
number |
Returns the heading of the current map view. |
|
getHeight |
|
number |
Returns the height of the map control. |
|
getImageryId |
|
string |
Returns the string that represents the imagery currently displayed on the map. |
|
getMapTypeId |
|
string |
Returns a string that represents the current map type displayed on the map. Valid map types are listed in the MapTypeId Enumeration topic. |
|
getMetersPerPixel |
|
number |
Returns the current scale in meters per pixel of the center of the map. |
|
getMode |
|
Returns the current map mode. |
|
|
getModeLayer |
|
Node |
Returns the map’s mode node. |
|
getOptions |
|
Returns the map options that have been set. Note that if an option is not set, then the default value for that option is assumed and getOptions returns undefined for that option. |
|
|
getPageX |
|
number |
Returns the x coordinate of the top left corner of the map control, relative to the page. |
|
getPageY |
|
number |
Returns the y coordinate of the top left corner of the map control, relative to the page. |
|
getRootElement |
|
Node |
Returns the map’s root node. |
|
getTargetBounds |
|
Returns the location rectangle that defines the boundaries of the view to which the map is navigating. |
|
|
getTargetCenter |
|
Returns the center location of the view to which the map is navigating. |
|
|
getTargetHeading |
|
number |
Returns the heading of the view to which the map is navigating. |
|
getTargetMetersPerPixel |
|
number |
Returns the scale in meters per pixel of the center of the view to which the map is navigating. |
|
getTargetZoom |
|
number |
Returns the zoom level of the view to which the map is navigating. |
|
getUserLayer |
|
Node |
Returns the map’s user node. |
|
getViewportX |
|
number |
Returns the x coordinate of the viewport origin (the center of the map), relative to the page. |
|
getViewportY |
|
number |
Returns the y coordinate of the viewport origin (the center of the map), relative to the page. |
|
getWidth |
|
number |
Returns the width of the map control. |
|
getZoom |
|
number |
Returns the zoom level of the current map view. |
|
getZoomRange |
|
object:{min:number, max: number} |
Returns the range of valid zoom levels for the current map view. |
|
isDownloadingTiles |
|
boolean |
Returns a boolean indicating whether map imagery tiles are currently being downloaded. |
|
isMercator |
|
boolean |
Returns a boolean indicating whether the map is in a regular Mercator nadir mode. |
|
isRotationEnabled |
|
boolean |
Returns true if the current map type allows the heading to change; false if the display heading is fixed. |
|
setMapType |
|
None |
Sets the current map type. The specified |
|
setOptions |
|
None |
Sets the height and width of the map. |
|
setView |
|
None |
Sets the map view based on the specified options. |
|
tryLocationToPixel |
|
Converts a specified Location to a Point on the map relative to the specified PixelReference. If Alternatively, converts an array of Locations and returns an array of Points if all locations were converted. If any of the conversions fail, null is returned. |
|
|
tryPixelToLocation |
|
Converts a specified Point to a Location on the map relative to the specified PixelReference. If Alternatively, converts an array of Points and returns an array of Locations if all points were converted. If any of the conversions fail, null is returned. |
Events
| Name | Arguments | Description |
|---|---|---|
|
click |
eventArgs:MouseEventArgs |
Occurs when the mouse is used to click the map. |
|
copyrightchanged |
None |
Occurs when the copyright of the map changes. |
|
dblclick |
eventArgs:MouseEventArgs |
Occurs when the mouse is used to double click the map. |
|
imagerychanged |
None |
Occurs when the underlying imagery used by the map changes. This is different from the maptypechanged event, which occurs when the map type being used is changed. |
|
keydown |
eventArgs:KeyEventArgs |
Occurs when a keyboard key is pressed down. |
|
keypress |
eventArgs:KeyEventArgs |
Occurs when a keyboard key is pressed. |
|
keyup |
eventArgs:KeyEventArgs |
Occurs when a keyboard key that is pressed down is released. |
|
maptypechanged |
None |
Occurs when the map type changes. |
|
mousedown |
eventArgs:MouseEventArgs |
Occurs when the left mouse button is pressed when the mouse cursor is over the map. |
|
mousemove |
eventArgs:MouseEventArgs |
Occurs when the mouse cursor moves over the map. |
|
mouseout |
eventArgs:MouseEventArgs |
Occurs when the mouse cursor moves out of the area covered by the map. |
|
mouseover |
eventArgs:MouseEventArgs |
Occurs when the mouse is over the map. |
|
mouseup |
eventArgs:MouseEventArgs |
Occurs when the left mouse button is lifted up when the mouse cursor is over the map. |
|
mousewheel |
eventArgs:MouseEventArgs |
Occurs when the mouse wheel is used when the mouse cursor is over the map. |
|
rightclick |
eventArgs:MouseEventArgs |
Occurs when the right mouse button is used to click the map. |
|
targetviewchanged |
None |
Occurs when the view towards which the map is navigating changes. |
|
tiledownloadcomplete |
None |
Occurs when all the map tiles of a map view have loaded. |
|
viewchange |
None |
Occurs for every frame of a map view change. |
|
viewchangeend |
None |
Occurs when the map view is done changing. This event occurs when a view is the same for one frame of a map view change. For example, if the mouse is used to drag the map to change the view, but pauses during the drag (without releasing the mouse button), viewchangeend occurs twice. You can use the addThrottledHandler method to customize the number of events that occur. |
|
viewchangestart |
None |
Occurs when the map view starts changing. |
Example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
<script type="text/javascript">
var map = null;
function GetMap()
{
// Initialize the map
map = new Microsoft.Maps.Map(document.getElementById("myMap"),
{credentials:"Bing Maps Key"});
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
</body>
</html>