Current Virtual Earth supports pushpins, polylines, and polygons. Another commonly used shape type that is used in other mapping applications is MultiShape or MultiGeometry. Not having this in Virtual Earth has been an issue for some users. I have put together a javascript file that can be loaded after the Virtual Earth map control that creates a MultiShape class that can be used with Virtual Earth. This new shape object takes in an array of VEShape objects and has methods to add and remove shapes from the object. Many of the functionalities that exist in the VEShape class exist in the MultiShape class. The VEMap and VEShapelayer classes have been extended in order to support this adding and removing of the MultiShape objects from the map using the existing methods in Virtual Earth. This javascript file and a simple sample html file can be downloaded here:
http://cid-e7dba9a4bfd458c5.skydrive.live.com/self.aspx/VE%20Tools/MultiShape.zip
Note: Since this extends the VEMap and VEShapeLayer classes by accessing undocumented methods in the map control it is possible that those methods may change without notice. This may result in unexpected errors occurring in the future.
Browsers tested: IE7, FF2
Virtual Earth versions tested: 5, 6, 6.1, 6.2
MultiShape Constructor
var x = new MultiShape(shapes);
Parameter | Descrption |
shapes | An array of VEShape objects to be added. Optional. |
Public Methods
These methods can be used in the same way as the equivalent methods in the VEShape object.
Method | Description |
SetDescription | Sets the description of the MultiShape object. |
GetDescription | Gets the description of the MultiShape object. |
SetTitle | Sets the title of the MultiShape object. |
GetTitle | Gets the title of the MultiShape object. |
GetAltitudeMode | Gets the mode in which the shape’s altitude is represented. |
SetAltitudeMode | Specifies the mode in which a shape’s altitude is represented. |
GetAltitude | Returns the altitude for the shape. |
SetAltitude | Specifies the altitude for the shape. |
GetCustomIcon | Gets the MultiShape object’s custom icon. |
SetCustomIcon | Sets the MultiShape object’s custom icon. |
GetFillColor | Gets the fill color and transparency used for all polygons. The default is null, unless a fill color is set for the MultiShape object. |
SetFillColor | Sets the fill color and transparency for all polygons in the MultiShape object. |
GetIconAnchor | Gets a VELatLong Class object representing the MultiShape’s custom icon anchor point. |
SetIconAnchor | Sets the info box anchor of the MultiShape object. |
GetLineColor | Gets the line color or transparency for all polylines or polygons. The default is null, unless a line color is set for the MultiShape object. |
SetLineColor | Sets the line color or transparency for all polylines or polygons in the MultiShape object. |
GetLineWidth | Gets the line width of all polylines or polygons. The default is null, unless a line width is set for the MultiShape object. |
SetLineWidth | Sets the line width for all polylines or polygons in the MultiShape object. |
Hide | Hides the specified MultiShape object from view |
Show | Makes the specified MultiShape object visible. |
HideIcon | Hides the icon associated with the MultiShape object. |
ShowIcon | Shows the icon associated with the MultiShape object. |
SetMinZoomLevel | Sets the minimum zoom level at which the shape is visible |
GetMinZoomLevel | Gets the minimum zoom level at which the shape is visible |
SetMaxZoomLevel | Sets the maximum zoom level at which the shape is visible |
GetMaxZoomLevel | Gets the maximum zoom level at which the shape is visible. |
SetPhotoURL | Sets the shape’s "photo" URL. |
GetPhotoURL | Gets the shape’s "photo" URL. |
GetMoreInfoURL | Gets the shape’s "more info" URL. |
SetMoreInfoURL | Sets the shape’s "more info" URL. |
SetZIndex | Sets the z-index value for all shapes in the MultiShape object. |
GetZIndex | Gets the z-index of a pushpin shape or pushpin attached to a polyline or polygon. The default is null, unless a z-index is set for the MultiShape object. |
GetID | Gets the internal identifier of the MultiShape object. |
GetShapeLayer | Gets the reference to the layer containing the specified MultiShape object. |
GetShapeByIndex | Retrieves a reference to a VEShape object contained in this MultiShape object based on the specified index. |
These methods can be used in the same way as the equivalent methods in the VEShapeLayer class.
Method | Description |
AddShape | Add’s a VEShape object to the MultiShape object. |
DeleteShape | Remove’s a VEShape object to the MultiShape object. |
GetShapeByID | Retrieves a VEShape object from a MultiShape object by it’s id. |
GetBoundingRectangle | Retrieves a VELatLongRectangle which encloses all VEShapes that are in the MultiShape object |
GetShapeCount | Returns the number of shapes are in the MultiShape object. |
These are new methods which can be used with a MultiShape object.
Method | Description |
GetIconLocation | Gets a VELatLong Class object of the pushpin associated with the MultiShape object. |
SetIconlocation | Sets the location of the pushpin associated with the MultiShape object. |
IndexOfShape | Retrieves the index of a VEShape that is in a MultiShape object. |
Constructors
var x = MultShape.GetIconLocation();
var x = MultShape.SetIconlocation(latlong); where latlong is a VELatLong object.
var x = MultShape.IndexOfShape(shape); where shape is a VEShape object.
MultiShape properties
Property | Description |
id | The id used to identify the MultiShape object. |
shapes | The array of VEShape objects which are contained in the MultiShape object. |
pin | The pushpin used associated with the MultiShape object. |
Extended VEMap and VEShapeLayer method’s
The following methods have been extended to work when used with MultiShape objects.
Method | Description |
AddShape | Adds a MultiShape object to the map/shape layer. All VEShapes in the MultiShape object will have a parentId parameter which is the id of the MultiShape object. |
DeleteShape | Deletes a MultiShape object from any layer, including the base map layer. |
DeleteAllShapes | Deletes all shapes. |
GetShapeByID | Retrieves a reference to a MultiShape object contained in this layer based on the specified ID. |
ShowInfoBox | Shows an information box for the shape. |
hi, I want to set the mapview in VE3d as can be done in map control:-viewRect = new VELatLongRectangle(new VELatLong(topLeftLat,topLeftLng),new VELatLong(bottomRightLat,bottomRightLng), new VELatLong(topLeftLat,bottomRightLng),new VELatLong(bottomRightLat,topLeftLng));map.SetMapView(viewRect);How can i dot it?RegardsRamneek
Pingback: Advance Shapes in Bing Maps V7 « Ricky's Bing Maps Blog