Search code examples
c#mappoint

MapPoint 2011- DataMap(ShadedArea) - Visual Studio


I've got a question about adding a datamap to my current map in mappoint while importing data to a dataset.

So, i have an excel file that has the following columns in order: ID,Name,Adress,City,Country,PostalCode,Service,MoneyImport.

I'm creating a dataset to be used for the datamap:

object missing = System.Reflection.Missing.Value;
MapPoint.DataSet dataset = map.DataSets.ImportData(filename, missing,
                              MapPoint.GeoCountry.geoCountryItaly,
                              MapPoint.GeoDelimiter.geoDelimiterDefault,
                              MapPoint.GeoImportFlags.geoImportExcelSheet);

I'm using the "missing" value cause the MapPoint Application when running through the normal interface*(importing from the same excel file i use here)* recognises perfectly the datafields, so i don't have the need to specify their types by myself.

Then i'm tryin' to use this dataset in order to create the datamap i need. This map is supposed to display as shaded areas the "MONEYIMPORT field" on the map based on zoomlevel. When using the normal mappoint interface it does it smoothly with no problem and no errors at all.

 Object Import = 8;

 MapPoint.Field GainedMoney = dataset.Fields.get_Item(Import);

This two lines are ment to let me add to the GainedMoney field the values of the 8th column of excel by exctracting 'em from the dataset.

So further i add the datamap:

MapPoint.DataMap datamap =dataset.DisplayDataMap(MapPoint.GeoDataMapType.geoDataMapTypeShadedArea,               GainedMoney,
                ShowDataBy: MapPoint.GeoShowDataBy.geoShowByZoomLevel,
                DataRangeType: MapPoint.GeoDataRangeType.geoRangeTypeDefault,
                DataRangeOrder: MapPoint.GeoDataRangeOrder.geoRangeOrderDefault,
                ColorScheme: 13,
                CombineDataBy: MapPoint.GeoCombineDataBy.geoCombineByAdd);

So the MapPoint object model decides to throw me an error that says that the type of area i'm tryin' to add to the map cannot be recognized, so it has been impossible to add it to the map.

I've checked several times if the attributes i pass to the .DisplayDataMap are correct, and they are identical to the ones i choose when creating the datamap through the user interface of mappoint, and still no result gained. Really i don't know anymore how to fix this. If any of you would be able to help me and provide me a hint, please do so!

Thanks in advance, George.


Solution

  • There are some articles on MP2Kmag.com to help with DisplayDataMap. In particular, the arrays you pass in as parameters are tricky. Also, the book Programming MapPoint in .NET was a big help to me in dealing with the DisplayDataMap method.