PDA

View Full Version : DisplayData Map Error



freedyer
07-24-2012, 08:49 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 :( 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 :(

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 :)
Thanks in advance,
George.

Mattys Consulting
07-24-2012, 11:03 PM
George,

MapPoint doesn't offer territory by city; only census tract, postal code, county, state, country are used.
You can draw a shape and send behind roads.

freedyer
07-25-2012, 02:13 AM
George,

MapPoint doesn't offer territory by city; only census tract, postal code, county, state, country are used.
You can draw a shape and send behind roads.

Hey, first of all thanks for your fast answer!
So about the territory by postal code, would u please explain how should i pass the arguments to the method? I guess that i should set the postal code column as territory, but i what about the method? i mean:

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

the territoryfield is an array of MapPoint.Field type that contains 2 items :
territoryfield[0] = territorymap.Fields.get_Item(PostalCode);territory field[1] = territorymap.Fields.get_Item(Country);

I do so in order to set the territory map by postal-code + country --- the problem is that it doesn't work. How should i do in order to get a territory map displayed by postalcode? what am i doing wrong?
Sorry for this newbie question but this method stresses me insanely with it's "Invalid parameter" error:(
Thanks again for your time.

Mattys Consulting
07-25-2012, 07:41 AM
You need one field to designate how the territories will be created and one field to label the names:
Dim arZips(1, 1) As Variant
arZips(0, 0) = "Zip": arZips(0, 1) = geoFieldPostal1
arZips(1, 0) = "TerrID": arZips(1, 1) = geoFieldTerritory
Set oDS = oMap.DataSets.ImportTerritories(strFileName, arZips, geoCountryUnitedStates, , geoImportAccessTable)

freedyer
07-26-2012, 09:26 AM
You need one field to designate how the territories will be created and one field to label the names:
Dim arZips(1, 1) As Variant
arZips(0, 0) = "Zip": arZips(0, 1) = geoFieldPostal1
arZips(1, 0) = "TerrID": arZips(1, 1) = geoFieldTerritory
Set oDS = oMap.DataSets.ImportTerritories(strFileName, arZips, geoCountryUnitedStates, , geoImportAccessTable)

Thanks, but the point is that when i use this dataset in order to display a map it gives me an error .
I've tried to use :

MapPoint.DataMap datamap = oDs.DisplayDataMap(MapPoint.GeoMapType.GeoMapTypeT erritory, other params)

and it errors... So i've been told that the displaydatamap doesn't accept the GeoMapTypeTerritory, so how to display the territory i load into my dataset then? How to make it show on the map?

Mattys Consulting
07-26-2012, 10:51 AM
I see. According to Winwaed (http://www.mapforums.com/sitemap/t-18539.html) GeoDataMapTypeTerritory isn't valid with DisplayDataMap