To accomplish this, I created a new administration page and edited the UINavigator and HeaderControl classes to add the new page to the menu. On this page were two dropdown lists which included the column names of a survey’s text entries. These lists were used to indicate where NSurvey stored the Country and Region questions. Together with a button that would generate the chart.

To generate the chart, all possible regions were first collected by grouping the entries and storing the unique country and regions. After this, the MapPoint FindService was instantiated and the Find method was called for each address.
FindServiceSoap findService =
new
FindServiceSoap();
if
(ConfigurationSettings.AppSettings["MapPointProxy"] !=
String.Empty) {
findService.Proxy =
this.proxyObject;
}
findService.Credentials =
this.ourCredentials;
findService.PreAuthenticate =
true;
FindSpecification findSpec =
new
FindSpecification();
findSpec.DataSourceName = "MapPoint.EU";
foreach
(DictionaryEntry locationEntry
in locationData) {
// key example: "West-Vlaanderen, BE"
findSpec.InputPlace = locationEntry.Key.ToString();
FindResults
foundResults = findService.Find(findSpec);
if
(foundResults.NumberFound > 0) {
((CustomLocation)locationEntry.Value).LatLong =
foundResults.Results[0].FoundLocation.LatLong;
}
}
This gave me the LatLong of every location MapPoint had found, which I used to create an array of Location objects to be passed to the GetBestMapView method. This method returned a MapViewRepresentations object which described to view to use when calling the GetMap method. This view assured every location was on it.
MapViewRepresentations mapRepresentations =
renderService.GetBestMapView(myLocations,
"MapPoint.EU");
ViewByHeightWidth[] myViews =
new
ViewByHeightWidth[1];
myViews[0] = mapRepresentations.ByHeightWidth;
Pushpin[] myPushpins =
new
Pushpin[foundRegions.Count];
Int32 pinCounter = 0;
foreach
(DictionaryEntry foundRegion
in foundRegions) {
myPushpins[pinCounter] =
new Pushpin();
myPushpins[pinCounter].IconDataSource =
"MapPoint.Icons";
myPushpins[pinCounter].IconName = "1";
// Red pin
Int32
nrResults =
((CustomLocation)foundRegion.Value).ResultCount;
myPushpins[pinCounter].Label = String.Format("{0} {1}",
nrResults,
(nrResults == 1) ? "result" : "results");
myPushpins[pinCounter].LatLong =
(LatLong)foundRegion.Key;
myPushpins[pinCounter].ReturnsHotArea =
true;
myPushpins[pinCounter].PinID =
(CustomLocation)foundRegion.Value).Location();
pinCounter++;
}
To get the map, I had to call the GetMap method and supply a MapSpecification. This specification describes the size of the map, the quality, the pushpins and what MapPoint should return. Here, it will return a URL, pointing to the generated map.
MapSpecification mapSpec =
new
MapSpecification();
mapSpec.DataSourceName = "MapPoint.EU";
mapSpec.Views = myViews;
mapSpec.Options =
new MapOptions();
mapSpec.Options.ReturnType =
MapReturnType.ReturnUrl;
mapSpec.Options.Format =
new ImageFormat();
mapSpec.Options.Format.Height = 500;
mapSpec.Options.Format.Width = 500;
mapSpec.Options.Style = MapStyle.Locator;
mapSpec.Pushpins = myPushpins;
MapImage[] mapImages =
renderService.GetMap(mapSpec);
After the call, MapPoint returned a MapImage object, containg the url to the map, together with information about the special areas on the map, called HotAreas. To make these areas clickable on the map, an HTML imagemap had to be generated.
StringBuilder imageMapName =
new
StringBuilder();
imageMapName.Append("<map
name=\"").Append(mapObject.ID);
imageMapName.Append("_Map\">");
for
(Int32 i = 0; i < hotAreas.Length; i++) {
String pinId =
hotAreas[i].PinID;
imageMapName.Append("\n<area shape=rect
coords=\"");
imageMapName.Append(hotAreas[i].IconRectangle.Left).Append(",");
imageMapName.Append(hotAreas[i].IconRectangle.Top).Append(",");
imageMapName.Append(hotAreas[i].IconRectangle.Right).Append(",");
imageMapName.Append(hotAreas[i].IconRectangle.Bottom);
imageMapName.Append("\"
title=\"").Append(pinId).Append("\">");
}
imageMapName.Append("</map>");
this.imageMapHotAreas.Text = imageMapName.ToString();
mapObject.Attributes["USEMAP"] = "#" + mapObject.ID +
"_Map";

This made it possible to visualize the results per region, and when you select a certain region, provide filtered results of that region.