PDA

View Full Version : FIXED: Type Mismatch in DisplayDataMap



gavin
07-15-2005, 04:41 AM
Hi,

Currently im using Delphi7 to link data from a CSV, one field in the CSV is the symbol# to use, now i know that this carnt be mapped at load so i have been trying to use DisplayDataMap but when i try to use this function with geoMapTypeMulitpleSymbol i get a "Type Mismatch" exception each time, no matter what i seem to pass to it.
Id appreciate it if someone could review that paramerters im passing, the most frustating thing is. is that it all looks reasonable to me.
oh i also tried moveing the array index from 1 to 4 incase it was something to do with that, it sill caused the same problem.
Here is the code of the procdure that maps the data after it has been linked,


procedure TMapForm.MapSymbols;
var
dMap : DataMap;
DataSetToUse: DataSet;
Index: OleVariant;
DataMapType: GeoDataMapType;
DataField: Field;
ShowDataBy: GeoShowDataBy;
CombineDataBy: GeoCombineDataBy;
DataRangeType: GeoDataRangeType;
DataRangeOrder: GeoDataRangeOrder;
ColorScheme: Integer;
DataRangeCount: Integer;
ArrayOfCustomValues: OleVariant;
ArrayOfCustomNames: OleVariant;
DivideByField: OleVariant;
ArrayOfDataFieldLabels: OleVariant;
ArrayOfPushpinSymbols: OleVariant;
begin
Index := 'Index0';
DataSetToUse := mpcCameraMap.ActiveMap.DataSets.Item[Index];

DataMapType := geoDataMapTypeMultipleSymbol;
Index := 'Symbol';
DataField := DataSetToUse.Fields[Index];
ShowDataBy := geoShowByDefault;
CombineDataBy := geoCombineByNone;
DataRangeType := geoRangeTypeUniqueValues;
DataRangeOrder := geoRangeOrderLowToHigh;
ColorScheme := 0;
DataRangeCount := 4;
ArrayOfCustomValues := VarArrayCreate([0,3], varVariant);
ArrayOfCustomValues[0] := 111;
ArrayOfCustomValues[1] := 122;
ArrayOfCustomValues[2] := 123;
ArrayOfCustomValues[3] := 133;

ArrayOfCustomNames := VarArrayCreate([0,3], varVariant);
ArrayOfCustomNames[0] := 'sym0';
ArrayOfCustomNames[1] := 'sym1';
ArrayOfCustomNames[2] := 'sym2';
ArrayOfCustomNames[3] := 'sym3';
DivideByField := '';
ArrayOfDataFieldLabels := VarArrayCreate([0,3], varVariant);
ArrayOfDataFieldLabels[0] := '111';
ArrayOfDataFieldLabels[1] := '122';
ArrayOfDataFieldLabels[2] := '123';
ArrayOfDataFieldLabels[3] := '133';
ArrayOfPushpinSymbols := VarArrayCreate([0,3], varVariant);
ArrayOfPushpinSymbols[0] := 10;
ArrayOfPushpinSymbols[1] := 20;
ArrayOfPushpinSymbols[2] := 30;
ArrayOfPushpinSymbols[3] := 40;


dMap := DataSetToUse.DisplayDataMap(
DataMapType,
DataField,
ShowDataBy,
CombineDataBy,
DataRangeType,
DataRangeOrder,
ColorScheme,
DataRangeCount,
ArrayOfCustomValues,
ArrayOfCustomNames,
DivideByField,
ArrayOfDataFieldLabels,
ArrayOfPushpinSymbols);

Eric Frost
07-18-2005, 07:47 AM
I have always struggled with DisplayDataMap when I have tried to use it.

One thing you might consider as a workaround since it is symbols is to render each Pushpin individually.. this should be much simpler and easier to troubleshoot.

Eric

gavin
07-19-2005, 05:36 AM
Hi Eric,

Unfortunatly that was the way we were doing it however this proved far to slow, it took 50 seconds to load 100 pushpins wiht custom symbols which is unacceptable in our application. it looked like DisplayMapData would solve this problem...



gav.

Eric Frost
07-19-2005, 07:39 AM
OK.. yes, it still probably can speed things up for you.

You might try coding it in VB6 or VBA/Excel first to prove that it can work for you and you have all the parameters and then port it to Delphi..

Also, search this forum for others with Delphi issues, perhaps someone here has already posted a solution.

Eric

gavin
07-27-2005, 10:10 AM
OK this is mainly for delphi developers however it may have some relevance to other languages.

Firstly in delphi using activex you cannot have optional parameters,
we found that you must use EmptyParam if you wish to pass no data, we were using NULL or ''.

Ok the main reason why the above code wasnt working was that we did not need a DivideByField so used an empty string in place for this param.
this is why we were getting the error because (we think) that it was looking for the field name '' which is why it threw the exception.
we then found out about the EmptyParam thing and used that instead and this cured our problem.

Hope this is of use to others!.

Yazzy
08-22-2005, 04:50 AM
Hi Have you solved the problem?

If not I could send a code sample in VB6?