stephenmillington
09-10-2007, 05:10 AM
Can anyone give me some code that shows how to use the AddPolyline method to the shapes collection in Delphi. The number of points is dynamic. I have tried the following (VertexList just contains the list of points where each item is Latitude,Longitude
var
VertexList: TStringList;
LocationArray: array of variant;
begin
SetLength(LocationArray, VertexList.Count);
for i := 0 to VertexList.Count - 1 do
begin
LocationArray[i] := oMap.GetLocation(Piece(VertexList[i],',', 1), Piece(VertexList[i], ',', 2));
end;
oMap.Shapes.AddPolyline(VarArrayRef(LocationArray) );
This does actually draw the polyline but I get an access violation in oleaut32.dll. This seems to be when the procedure ends. I can only think this is something to do with the array being freed.
var
VertexList: TStringList;
LocationArray: array of variant;
begin
SetLength(LocationArray, VertexList.Count);
for i := 0 to VertexList.Count - 1 do
begin
LocationArray[i] := oMap.GetLocation(Piece(VertexList[i],',', 1), Piece(VertexList[i], ',', 2));
end;
oMap.Shapes.AddPolyline(VarArrayRef(LocationArray) );
This does actually draw the polyline but I get an access violation in oleaut32.dll. This seems to be when the procedure ends. I can only think this is something to do with the array being freed.