| Ricky's profileRicky's Bing Maps BlogBlogSkyDrive | Help |
|
|
2/22/2009 Drawing Routes with the VE Web ServiceThe Virtual Earth web services are fairly new and as such it does not currently have all the capabilities of it's JavaScript counter part. One key functionality that is not currently available is the ability to draw routes on a map image. This can be done by extending the methods described in the article "VE Imagery Service Polygons and Polylines" found here: http://rbrundritt.spaces.live.com/blog/cns!E7DBA9A4BFD458C5!497.entry In order to display a route on a map image the following steps will have to be taken: 1) Geocode the start and end points of the route using the Geocoding service. 2) Calculate a Route and have the route geometry returned using the Routing Service. 3) Calculate the best map view for the route path. 4) Request map image from the imagery service that matches the best map view calculated in step 3. 5) Draw the route line on the map image using .NET drawing tools. 6) Draw the route turn points on the map image using .NET drawing tools. Below is an example of a route that was created using the above method. Complete sample code can be found here: http://cid-e7dba9a4bfd458c5.skydrive.live.com/self.aspx/VE%20Sample%20code/VERouteImageryService.zip 2/17/2009 Advance Polygon shapes in Virtual EarthVirtual Earth currently supports polygons that consist of a single array of points. Many geospatial systems have complex polygons which may consist of several arrays of points which are a combination of outer and inner arrays of points. These are often referred to as Multipolygons. Multipolygons are often used to represent complex boundary areas such as "donut" shaped polygons. By properly concatenating inner and outer polygon array segments in the proper order a single array can be created to represent a complex polygon. An array of polylines can then be created to represent the edges of the polygon. The following method takes in an array of inner and outer polygon array segments and returns and an array of shapes. This array consists of a polygon and and several polylines. This array of shapes can then be added to the map either by looping through each shape and adding it to the map, or by passing the array through the MultiShape class described here: http://rbrundritt.spaces.live.com/blog/cns!E7DBA9A4BFD458C5!605.entry The MultiShape class will give you greater control of the complex polygon.
Below is an example of a complex polygon that was created using the above method. Complete sample code for this polygon can be found here: http://cid-e7dba9a4bfd458c5.skydrive.live.com/self.aspx/VE%20Sample%20code/AdvancePolygon.zip 2/14/2009 VEImagery Service Pixel to LatLong calculations
The VEImagery service gives us the ability to render static versions of Virtual Earth Maps. As handy as this is it would also be handy to be able to georeference the image that is returned. The article found here: http://rbrundritt.spaces.live.com/blog/cns!E7DBA9A4BFD458C5!488.entry explains how to convert from LatLong to Pixel so that custom icons could be added to the map, however the conversion from Pixel to LatLong was not needed at that time. Building on top of the code that was provided in that article the following method can be used to calculate a LatLong value based on the pixel coordinate of a static image. The following formula can be used to perform this calculation.
The complete source code can be downloaded here: http://cid-e7dba9a4bfd458c5.skydrive.live.com/self.aspx/VE%20Sample%20code/CustomIconVEService.zip Here is a screen shot of this application in action. 2/5/2009 MultiShapes and Virtual Earth
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);
Public Methods These methods can be used in the same way as the equivalent methods in the VEShape object.
These methods can be used in the same way as the equivalent methods in the VEShapeLayer class.
These are new methods which can be used with 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
Extended VEMap and VEShapeLayer method's The following methods have been extended to work when used with MultiShape objects.
|
|
|