Using the Core Map Control

You are not viewing the latest version of the AJAX control. Bing Maps AJAX V7 is the recommended JavaScript control for Bing Maps. If you need this documentation, it is available in as a CHM or PDF download.

If you do not need enhanced map features, you can improve the performance of your application by using the core version of the map control. This topic includes information about how to load the core map control as well as the map control APIs that are supported in the core version.

Loading the Core Map Control

To load the core map control, set the v parameter of the map control to 6.3c. Your script tag in the header of your web page now looks like this:

<script charset="UTF-8" type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3c&mkt=en-us"></script>

Core Map Control API

The following APIs are supported in the core version of Bing Maps AJAX Control 6.3. If you need geocoding or search functionality, you can use the Bing Maps REST Services in conjunction with the core map control as described in the Using the REST Services with the Core Map Control topic.

Note

The core version of the map control is only supported on the following browsers: Internet Explorer 7, Internet Explorer 8, Firefox 3.5, Firefox 3.6, Safari 4, and Google Chrome.

Supported Types

Type Supported Members

VEDistanceUnit Enumeration

All members are supported.

VEException Class

All members are supported.

VELatLong Class

All members are supported.

VELatLongRectangle Class

All members are supported.

VEMap Class

Supported members are listed in the VEMap member tables below.

VEMapOptions Class

All members are supported.

VEMapStyle Enumeration

All members are supported.

VEMapViewSpecification Class

All members are supported.

VEPixel Class

All members are supported.

VEShape Class

Supported members are listed in the VEShape member tables below.

VEShapeLayer Class

Supported members are listed in the VEShapeLayer member tables below.

VEShapeType Enumeration

VEShapeType.Pushpin

VETileSourceSpecification Class

All members are supported.

Supported VEMap Members

The following members of the VEMap Class are supported in the core version of the map control.

Public Constructor

Name Description

VEMap Constructor

Initializes a new instance of the VEMap Class.

Public Events

Name Description

VEMap.onkeypress Event

Occurs when a key is pressed and released.

VEMap.onkeydown Event

Occurs when a key is pressed (but before it is released).

VEMap.onkeyup Event

Occurs when a key is released.

VEMap.onclick Event

Occurs when a left or right mouse button is single-clicked.

VEMap.ondoubleclick Event

Occurs when a left mouse button is double-clicked.

VEMap.onmousedown Event

Occurs when a mouse button (left, right, or middle) is clicked (but before it is released).

VEMap.onmousemove Event

Occurs when the mouse cursor moves.

VEMap.onmouseout Event

Occurs when the mouse cursor moves away from a VEShape object.

VEMap.onmouseover Event

Occurs when the mouse cursor moves over a VEShape Class object.

VEMap.onmouseup Event

Occurs when a mouse button (left, right, or middle) is released.

VEMap.onmousewheel Event

Occurs when the mouse wheel is moved.

VEMap.onchangemapstyle Event

Occurs when the map style changes.

VEMap.onchangeview Event

Occurs whenever the map view changes.

VEMap.oncredentialserror Event

Occurs when the map control makes a request to the Bing Maps servers and the credentials that were set using the VEMap.SetCredentials Method are invalid.

VEMap.oncredentialsvalid Event

Occurs when the map control makes a request to the Bing Maps servers and the credentials that were set using the VEMap.SetCredentials Method are valid.

VEMap.onendpan Event

Occurs when a pan of the map ends.

VEMap.onendzoom Event

Occurs when the map zoom ends.

VEMap.onerror Event

Occurs when there is a map control error.

VEMap.oninitmode Event

Occurs after the map mode changes and the map has reloaded.

VEMap.onresize Event

Occurs when the map is resized.

VEMap.onstartpan Event

Occurs when a pan of the map begins.

VEMap.onstartzoom Event

Occurs when the map zoom begins.

Public Methods

Name Description

VEMap.AddControl Method

Adds a custom control to the map.

VEMap.AddCustomLayer Method

Adds a custom layer to the map.

VEMap.AddShape Method

Adds an existing VEShape Class object, as specified by the shape parameter, to the base layer. The core version of this method does not support adding shape arrays. Also note that the core version of the map control only supports VEShape objects that are of type VEShapeType.Pushpin.

VEMap.AddShapeLayer Method

Adds the specified shape layer to the map.

VEMap.AddTileLayer Method

Adds a tile layer to the map, and if the visibleOnLoad parameter is true, it also shows it on the map.

VEMap.AttachEvent Method

Attaches a Map Control event to a specified function.

VEMap.Clear Method

Removes all shapes, shape layers, and search results on the map. Also removes the route from the map, if one is displayed.

VEMap.ClearInfoBoxStyles Method

Clears out all of the default Bing Maps info box CSS styles.

VEMap.ClearTraffic Method

Clears the traffic map.

VEMap.DeleteControl Method

Removes the specified control from the map.

VEMap.DeleteAllShapes Method

Deletes all shapes in all layers, leaving empty layers behind.

VEMap.DeleteAllShapeLayers Method

Deletes all shape layers, along with any shapes within the layers.

VEMap.DeleteShape Method

Deletes a VEShape Class object from any layer, including the base map layer.

VEMap.DeleteShapeLayer Method

Deletes the specified shape layer from the map.

VEMap.DeleteTileLayer Method

Deletes a tile layer from view.

VEMap.DetachEvent Method

Detaches the specified map control event so that it no longer calls the specified function.

VEMap.Dispose Method

Deletes the VEMap object and releases any associated resources

VEMap.EndContinuousPan Method

Stops the continuous map panning initiated by a call to the VEMap.StartContinuousPan Method.

VEMap.GetCenter Method

Returns a VELatLong Class object that represents the location of the center of the current map view.

VEMap.GetLeft Method

Returns the pixel value of the left edge of the map control.

VEMap.GetMapStyle Method

Returns the current map style.

VEMap.GetMapView Method

Returns the current map view object as a VELatLongRectangle Class object.

VEMap.GetShapeByID Method

Gets the reference to a VEShape Class object based on its internal identifier.

VEMap.GetShapeLayerByIndex Method

Gets the reference to a VEShapeLayer Class object based on its index.

VEMap.GetShapeLayerCount Method

Gets the total number of shape layers on the map.

VEMap.GetTileLayerByID Method

Gets a tile layer based upon its identifier.

VEMap.GetTileLayerByIndex Method

Gets a tile layer based upon an index value.

VEMap.GetTileLayerCount Method

Gets the number of tile layers.

VEMap.GetTop Method

Returns the pixel value of the top edge of the map control.

VEMap.GetVersion Method

Returns the current version of the map control.

VEMap.GetZoomLevel Method

Returns the current zoom level of the map.

VEMap.HideBaseTileLayer Method

Hides the base tile layer of the map.

VEMap.HideControl Method

Hides the specified control from view.

VEMap.HideDashboard Method

Hides the default user interface for controlling the map (the compass and the zoom control).

VEMap.HideInfoBox Method

Hides a shape's custom or default info box.

VEMap.HideScalebar Method

Hides the scale bar from the map.

VEMap.HideAllShapeLayers Method

Hides all of the shape layers on the map.

VEMap.HideTileLayer Method

Hides a tile layer from view.

VEMap.HideTrafficLegend Method

Hides the traffic legend.

VEMap.IncludePointInView Method

Changes the map view so that it includes both the specified VELatLong Class point and the center point of the current map.

VEMap.LatLongToPixel Method

Converts an array of VELatLong Class objects (latitude/longitude pair) to an array of VEPixel Class objects.

VEMap.LoadMap Method

Loads the specified map. All parameters are optional.

VEMap.LoadTraffic Method

Loads the traffic map.

VEMap.Pan Method

Moves the map the specified amount.

VEMap.PanToLatLong Method

Pans the map to a specific latitude and longitude.

VEMap.PixelToLatLong Method

Converts a pixel (a point on the map) to a VELatLong Class object (latitude/longitude pair).

VEMap.RemoveCustomLayer Method

Removes a custom layer from the map.

VEMap.Resize Method

Resizes the map based on the specified width and height.

VEMap.SetCenter Method

Centers the map to a specific latitude and longitude.

VEMap.SetCenterAndZoom Method

Centers the map to a specific latitude and longitude and sets the zoom level.

VEMap.SetCredentials Method

Sets the credentials to use to authenticate map service requests.

VEMap.SetDefaultInfoBoxStyles Method

Sets the info box CSS styles back to their original classes.

VEMap.SetMapStyle Method

Sets the style of the map.

VEMap.SetMapView Method

Sets the map view to include all of the points, lines, or polygons specified in the provided array, or to the view defined by a VEMapViewSpecification Class object.

VEMap.SetMouseWheelZoomToCenter Method

Specifies whether to zoom to the center of the screen or to the cursor position on the screen.

VEMap.SetScaleBarDistanceUnit Method

Sets the distance unit (kilometers or miles) for the map scale.

VEMap.SetTileBuffer Method

Sets the number of "rings" of map tiles that should be loaded outside of the visible mapview area.

VEMap.SetTrafficLegendText Method

Specifies the text shown with the traffic legend, if visible.

VEMap.SetZoomLevel Method

Sets the view of the map to the specified zoom level.

VEMap.ShowAllShapeLayers Method

Shows all shape layers on the map.

VEMap.ShowBaseTileLayer Method

Shows the base tile layer of the map.

VEMap.ShowControl Method

Makes the specified control visible. This method only affects control elements that have been hidden from view using the VEMap.HideControl Method.

VEMap.ShowDashboard Method

Shows the default user interface for controlling the map (the compass-and-zoom control). By default, this control is shown.

VEMap.ShowInfoBox Method

Shows a shape's custom or default info box.

VEMap.ShowMessage Method

Displays the specified message in a dialog box on the map.

VEMap.ShowScalebar Method

Displays the scale bar on the map.

VEMap.ShowTileLayer Method

Shows a tile layer from view.

VEMap.ShowTrafficLegend Method

Displays the traffic legend.

VEMap.StartContinuousPan Method

Moves the map in the specified direction until the VEMap.EndContinuousPan Method is called.

VEMap.ZoomIn Method

Increases the map zoom level by 1.

VEMap.ZoomOut Method

Decreases the map zoom level by 1.

Public Properties

Name Description

VEMap.onLoadMap Property

Specifies the function to call when the map is first loaded.

Supported VEShape Members

The following members of the VEShape Class are supported in the core version of the map control.

Note

The core version of the map control only supports VEShape objects that are of type VEShapeType.Pushpin.

Public Constructor

Name Description

VEShape Constructor

Initializes a new instance of the VEShape Class.

Public Events

Name Description

VEShape.ondrag Event

Occurs when a shape is being dragged across the map.

VEShape.onenddrag Event

Occurs when a shape drag has stopped.

VEShape.onstartdrag Event

Occurs when the user starts dragging the shape.

Public Methods

Name Description

VEShape.GetCustomIcon Method

Gets the VEShape object's custom icon.

VEShape.GetDescription Method

Gets the description of the VEShape object.

VEShape.GetIconAnchor Method

Gets a VELatLong Class object representing the shape's custom icon anchor point.

VEShape.GetID Method

Gets the internal identifier of the VEShape object.

VEShape.GetMaxZoomLevel Method

Gets the maximum zoom level at which the shape is visible.

VEShape.GetMinZoomLevel Method

Gets the minimum zoom level at which the shape is visible.

VEShape.GetPoints Method

Returns an array of VELatLong Class objects representing the points that make up the pushpin.

VEShape.GetShapeLayer Method

Gets the reference to the layer containing the specified VEShape object.

VEShape.GetTitle Method

Gets the title of the VEShape object.

VEShape.GetType Method

Gets the type of the VEShape object.

VEShape.GetZIndex Method

Gets the z-index of a pushpin shape.

VEShape.Hide Method

Hides the specified VEShape object from view.

VEShape.SetCustomIcon Method

Sets the VEShape object's custom icon.

VEShape.SetDescription Method

Sets the description of the VEShape object.

VEShape.SetIconAnchor Method

Sets the info box anchor of the VEShape object.

VEShape.SetMaxZoomLevel Method

Sets the maximum zoom level at which the shape is visible.

VEShape.SetMinZoomLevel Method

Sets the minimum zoom level at which the shape is visible.

VEShape.SetPoints Method

Sets the points of the VEShape object.

VEShape.SetTitle Method

Sets the title of the VEShape object.

VEShape.SetZIndex Method

Sets the z-index value for a shape.

VEShape.Show Method

Makes the specified VEShape object visible.

Public Properties

Name Description

VEShape.Draggable Property

A Boolean value indicating whether the VEShape icon on the map can be dragged using the mouse.

Supported VEShapeLayer Members

The following members of the VEShapeLayer Class are supported in the core version of the map control.

Public Constructor

Name Description

VEShapeLayer Constructor

Initializes a new instance of the VEShapeLayer Class.

Public Methods

Name Description

VEShapeLayer.AddShape Method

Adds an existing VEShape Class object to the layer based on the specified VEShape reference. The core version of this method does not support adding shape arrays. Also note that the core version of the map control only supports VEShape objects that are of type VEShapeType.Pushpin.

VEShapeLayer.DeleteAllShapes Method

Deletes all VEShape objects from the layer.

VEShapeLayer.DeleteShape Method

Deletes a VEShape object from the current layer.

VEShapeLayer.GetBoundingRectangle Method

Returns a best-fit VELatLongRectangle Class object based on the shapes currently present in the layer.

VEShapeLayer.GetShapeByID Method

Retrieves a reference to a VEShape object contained in this layer based on the specified ID.

VEShapeLayer.GetShapeByIndex Method

Retrieves a reference to a VEShape object contained in this layer based on the specified index.

VEShapeLayer.GetShapeCount Method

Returns the total number of shapes in the current layer.

VEShapeLayer.IsVisible Method

Returns whether the layer is visible.

VEShapeLayer.Hide Method

Hides the layer from view on the map.

VEShapeLayer.Show Method

Shows the layer on the map.