PDA

View Full Version : Importing data from excel as territory, Help!



freedyer
07-24-2012, 08:51 AM
Hey all!
I've been browsing through this forum during the whole last week and seriusly i've found a lot of usefull tips. But today i'm fighting with a case-sensitive problem caused by my tentatives to select a territory on the map(in my case a region of italy) and color it how i want. So, i've tried multiple things and since now i gained no positive result :sad: At the moment i'm tryin' to create a Dataset and import a territory from an excel file :

territorymap = map.DataSets.ImportTerritories(filename, fieldSpecifications, MapPoint.GeoCountry.geoCountryItaly,
MapPoint.GeoDelimiter.geoDelimiterDefault);

territorymap is my dataset, map is the map i associated to the mappointcontrol in my form. The filename is the path to my excel file, fieldspecifications is the array of objects that describes my excel file :

object[,] fieldSpecifications = new object[7, 2];
fieldSpecifications[0, 0] = "ID";
fieldSpecifications[0, 1] = MapPoint.GeoFieldType.geoFieldSkipped;


fieldSpecifications[1, 0] = "Manager";
fieldSpecifications[1, 1] = MapPoint.GeoFieldType.geoFieldSkipped;


fieldSpecifications[2, 0] = "Adress";
fieldSpecifications[2, 1] = MapPoint.GeoFieldType.geoFieldAddress1;


fieldSpecifications[3, 0] = "City";
fieldSpecifications[3, 1] = MapPoint.GeoFieldType.geoFieldTerritory;


fieldSpecifications[4, 0] = "Country";
fieldSpecifications[4, 1] = MapPoint.GeoFieldType.geoFieldRegion1;


fieldSpecifications[5, 0] = "Postal_Code";
fieldSpecifications[5, 1] = MapPoint.GeoFieldType.geoFieldPostal1;


fieldSpecifications[6, 0] = "Service";
fieldSpecifications[6, 1] = MapPoint.GeoFieldType.geoFieldData;
---------------------------------------------------------------------------------------------------

So then i try to use this dataset on my datamap :

territoryfield[0] = territorymap.Fields.get_Item(City); City is an object with value 3


territoryfield[1] = territorymap.Fields.get_Item(Postal_Code); Postal is an object with value 5


dataterritory(this is my datamap) = territorymap.DisplayDataMap(MapPoint.GeoDataMapTyp e.geoDataMapTypeTerritory, territoryfield, MapPoint.GeoShowDataBy.geoShowByTerritory, ColorScheme: 5);

------------------So i get an error on this last line as : Invalid parameter or Access denied. Dunno what to do :sad:

I just want to select the territory "Udine" which is the value of the column City from my excel table, and add it as a territory on my map with a color.

If anyone can help i would be very thankfull :smile:
Thanks in advance,
George.

freedyer
07-26-2012, 08:02 AM
So the answer was : .DisplayDataMap(MapPoint.GeoDataMapTyp e.geoDataMapTypeTerritory) is not accepted. Seems displayDataMap Method doesn't accept the territoryType...
Thanks anyway to who tried to help me :)
Have a nice day,
George.