Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 5 of 5

How do I use AddPolyline method in Delphi

This is a discussion on How do I use AddPolyline method in Delphi within the Development forums, part of the MapPoint Desktop Discussion category; Can anyone give me some code that shows how to use the AddPolyline method to the shapes collection in Delphi. ...

  1. #1
    stephenmillington is offline Member Yellow Belt
    Join Date
    Jun 2004
    Posts
    40

    Question How do I use AddPolyline method in Delphi

    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.

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: How do I use AddPolyline method in Delphi

    Hi,

    If it is because the array being freed you can try to put it as a private member in your class instead of on the stack frame as you do now. Please let us know if this works. If not then please post the complete procedure.

    Oh yes and please put code into [ code ] tags. Then it shows up with the right indent and is much better to read

  3. #3
    stephenmillington is offline Member Yellow Belt
    Join Date
    Jun 2004
    Posts
    40

    Red face Re: How do I use AddPolyline method in Delphi

    Hi

    I tried moving the variable to a private member of my form but it made no difference which implied that wasn't the actual problem. I have now found a solution that works by making my LocationArray variable a variant and then using the VarArrayCreate function to create my array and then just passing my LocationArray variable to the AddPolyline method.

  4. #4
    stephenmillington is offline Member Yellow Belt
    Join Date
    Jun 2004
    Posts
    40

    Question Re: How do I use AddPolyline method in Delphi

    Hi

    According to the help file in order to make the polyline closed you need to create an extra vertex which is the same as the first one which is fine. However, how do I know if freeform shapes drawn on the map are closed since the vertices property just contains the different points, i.e. when a polyline is closed it doesn't contain an extra vertex for the start point and there isn't a property that tells you if it is closed.

    Stephen

  5. #5
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: How do I use AddPolyline method in Delphi

    Hi,

    I don't think you can see in the code if it is visually closed.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Addpolyline from a dataset
    By micheln in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 05-04-2007, 07:49 AM
  2. AddPolyLine (s) array problem
    By FreddyD in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 12-20-2006, 01:45 PM
  3. Shapes.AddPolyline is very slow
    By tdaffin in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 01-27-2006, 08:08 AM
  4. Addpolyline , Array , Visual Basic and Other languages
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 08-26-2004, 04:58 AM
  5. addpolyline
    By Anonymous in forum Wish List
    Replies: 2
    Last Post: 04-25-2003, 04:50 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66