Setting and Getting VEShape Object Properties
Once a shape has been added to a map you can use can use the class VEShape and its methods to get the properties of the shape. These properties control the attributes of the shape like color and width, custom icon, image file etc. the title and description properties can also contain custom html that may help you to further extend and modify your shapes.
Firstly you need to create an array of VELatLong objects. The capacity of the array depends upon the shape. I-e a polygon requires 3 points, a line requires 2 points and a pinpoint requires only one point. The code that can be used is, var points = new Array( new VELatLong(45.01188,-111.06687, 0, VEAltitudeMode. RelativeToGround), new VELatLong(45.01534,-104.06324, 0, VEAltitudeMode. RelativeToGround), new VELatLong(41.01929,-104.06, 0, VEAltitudeMode. RelativeToGround), new VELatLong(41.003,-111.05878, 0, VEAltitudeMode. RelativeToGround)).
Create a VEShape object. Here is the code, var myPolygon = new VEShape(VEShapeType.Polygon, points); the code creates a new polygon shape, "myPolygon", at the specified coordinates. Add the VEShape object named "myPolygon" to the map.
Edit the properties of the shape. myPolygon.SetTitle("My Polygon"); here the title is set; myPolygon.SetDescription("This is the description for my polygon."); the description in this code strings are added for the title and description of the shape.
For Adding a shape layer to a map use the following steps: First of all you need to initialize a new instance of the VEShapeLayer classVEShapeLayer Class. var myShapeLayer = new VEShapeLayer();. Now add the shape layer to the map, using the VEMap.AddShapeLayer Method. map.AddShapeLayer(myShapeLayer); Now you need Define an array of VELatLong objects.
var points = new Array( new VELatLong(45.01188,-111.06687, 0, VEAltitudeMode. RelativeToGround), new VELatLong(45.01534,-104.06324, 0, VEAltitudeMode. RelativeToGround), new VELatLong(41.01929,-104.06, 0, VEAltitudeMode. RelativeToGround), new VELatLong(41.003,-111.05878, 0, VEAltitudeMode. RelativeToGround) );
Once the array is created, create a VShape object to add to the map with this one, var myShape = new VEShape(VEShapeType.Polygon, points);
Now finally add the shape to the shape layer using the VEShapeLayer.AddShape method. myShapeLayer.AddShape(myShape);
Using Routing and Directions: Virtual Earth’s routing and driving directions feature can be used to show routes on your custom maps. You can write your own event handler to customize the driving directions.
Getting a route: To display a driving route from one place to another with a few point in between you have to call the VEMap.GetDirections Method. A point can be specified as an address, place name or a VELatLang class object. Both the following examples are valid. var myOptions = new VERouteOptions(); myOptions.SetBestMapView = false; // Don't change map view. myOptions.RouteCallback = myRouteHandler; this gets a VERoute. map.GetDirections(["space needle", "LA Coliseum", "area 51"], myOptions); map.GetDirections(["1 Microsoft Way, 98052", new VELatLong(47.969,-122.39, 0, VEAltitudeMode.RelativeToGround)], myOptions); now the route is drawn on the map complete with start point, end point and all the interim points icon.
Showing Driving Directions: The details about the route are stored in the VERoute object, including the details about the driving directions. When calling the GetDirections method, you can specify a callback function to handle the VERoute object and use the information to display driving directions.
Technorati Tags: Microsoft, virtual earth, using virtual earth, using virtual earth,
Tags: Microsoft Virtual Earth
























