18 March 2010

Virtual Earth & SSRS Integration

(Originally posted 27 March 2009).

Virtual Earth integration with SSRS can be a challenge due to uncertainty around approach and a general lack of resources on the topic. Developers can use three Virtual Earth APIs: the MapPoint Web Services, the Virtual Earth Map Control and the Virtual Earth Web Services. SSRS cannot currently use the Virtual Earth Map Control since this allows users to make requests via JavaScript to an AJAX map object and SSRS will not allow JavaScript to run (as otherwise it will not be able to export to PDF amongst other things). This would have been preferable since it affords a level of interactivity e.g. zooming-in on tiles. This leaves either the MapPoint Web Services or the Virtual Earth Web Services. Both methods effectively work the same in that points to plot are passed to the web service, rendered on the map server-side and passed back to the browser as an image. MSFT no longer develops MapPoint Web Services (although existing applications built using MapPoint Web Services will remain functional) so if you want Virtual Earth integration with SSRS, your only real choice is Virtual Earth Web Services. Here is a snippet on how to pass coordinates (Longitude/Latitude) to Virtual Earth. This should display a pushpin on the map (The Imagery Service is used).

You will need a Virtual Earth Platform Developer account and this itself will need a Windows Live ID. Once you have this, the SSRS report should call a function in a C# custom assembly, passing in an MDX query string to retrieve co-ordinates. The SSRS report only calls the custom assembly. The output of the function will be a URL for the map image to display on the report. The custom assembly queries the database/cube to retrieve co-ordinates for the points to plot. It should then call Virtual Earth Web Services passing through the co-ordinates to be plotted. Finally, the GetBestMapView method should be used within the assembly to scale the image appropriately e.g. if all points are plotted in the South East of England, the image needs to zoom in to the South East of England and not the whole of the UK.

No comments:

Post a Comment