Share via


Reporting Services: Dynamic zoom for maps in Reporting Services 2008 R2

The maps in reporting services miss one important feature: dynamic zoom. By this, I mean the ability for a user to zoom into the map while looking at the report and panning around to see the locations of interest. This is necessary for instance when you display the world map and wish to zoom into smaller countries or specific areas.

Unfortunately I did not find any ideal solution to this issue, however I will present here a (somewhat) acceptable solution, that allows the user to tweak zoom level while automatically centering on the locations of interest.

To start, I created a basic report that displays the world map, and visualizes country data from the AdventureWorksDW by color. For simplicity, I removed the legend and color scale, and this is what I have:

http://4.bp.blogspot.com/-58ISRFdKDzc/T3MqmZxbLkI/AAAAAAAAA4A/oGkxe3BzWRQ/s1600/blog_post5_1.PNG
Figure 1 - Starting map

The sample includes very few countries but that's okay.

What we will do is allow the user to specify the countries of interest, and the map automatically centers itself between those countries.

I modify my data set to take a list of countries as a parameter, and then add the list of countries as a report parameter.

http://4.bp.blogspot.com/-tCBm6sZpd8M/T3MvS5dWhyI/AAAAAAAAA4I/t2D7dMFLxQ4/s1600/blog_post5_2.PNG
Figure 2 - Countries parameter

The next step is to enable the automatic-centering between the countries of interest. To show you what I mean, I (for now) manually zoomed into the map and then with the report running, I selected only Australia. Figure 3 shows the result.

http://4.bp.blogspot.com/-jXTutsZI7PM/T3MwawzDYkI/AAAAAAAAA4Q/md22YieFfJk/s1600/blog_post5_3.PNG
Figure 3 - Map automatically centers on Australia

In order to do this, right click on the map (away from the polygons) and choose "Viewport Properties". Go into the "Center and Zoom" tab, and under "Change map view center and zoom options", select "Center map to show all data-bound map elements" as in the screenshot below.

http://3.bp.blogspot.com/-ewqnqwirsQk/T3MwzEWMHiI/AAAAAAAAA4Y/gLeE6FIH7gk/s1600/blog_post5_4.png
Figure 4 - Center map

Finally we need the ability to dynamically change the zoom level. This is the not-that-nice part, but it is so far the only possible way I found. In the same window as Figure 4, there is a Zoom level field. What we can do is create a report parameter of type integer (with default of 100) (Figure 5), and then link this zoom field to that parameter using expressions.

http://4.bp.blogspot.com/-H5ncM1A4Qak/T3MybKLqZ_I/AAAAAAAAA4o/5LR00F2xEWs/s1600/blog_post5_6.png
Figure 5 - ZoomLevel parameter

I called the parameter ZoomLevel, and now the viewport properties looks like Figure 6.

http://3.bp.blogspot.com/-c48hx95OPsM/T3Mx8A2gCVI/AAAAAAAAA4g/HfiRtNvbr7Y/s1600/blog_post5_5.png
Figure 6 - Map zoom level from parameter

The result is that the users can select countries of interest and then tweak the zoom level as they desire. For instance, I ran the report and chose Germany and United Kingdom as countries, and set the zoom level parameter to 1500, achieving the following result:

http://1.bp.blogspot.com/-7dYk8pkno4c/T3M0ih4iaEI/AAAAAAAAA4w/fChZdzCTcHg/s1600/blog_post5_7.PNG
Figure 7 - Map centered and zoomed

This solution is still far from the comfort of using the mouse wheel for zooming, and dragging the mouse to pan around, but it can be necessary particularly when one requires to look at the smaller countries. The ZoomLevel parameter can also be implemented as a list of pre-set zoom levels.