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 4 of 4

Vertices and VB.Net

This is a discussion on Vertices and VB.Net within the MapPoint Desktop Discussion forums, part of the Map Forums category; hi, i'm trying to use Vertices of shape drawen by user for later use. The problem is that i cant ...

  1. #1
    alon is offline Junior Member White Belt
    Join Date
    Jul 2004
    Posts
    1

    Vertices and VB.Net

    hi,
    i'm trying to use Vertices of shape drawen by user for later use.
    The problem is that i cant get the vertices content.
    here is a sample of my code:

    Me.MPCtl.NewMap(MapPoint.GeoMapRegion.geoMapNorthA merica)
    Dim iShape As MapPoint.Shape
    iShape = Me.MPCtl.ActiveMap.Shapes.Item(1)
    Dim MyMap As MapPoint.Map
    MyMap = Me.MPCtl.ActiveMap
    Dim MyLoc() As MapPoint.Location
    MyLoc = CType(iShape.Vertices, MapPoint.Location())

    (i'm using VB.Net with an activeX of MapPoint)

    now, the last line is doing my headache... the compiler saids it cant do the casting... BUT vertices is a collection of locations, isn't it ?
    another by the way question is - why do i need to do all those castings every where ? (i mean when using findresults, etc.) - i cant (dont want to) put the option explicit off ...


    thaks a lot,

    alon

  2. #2
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Vertices with C#

    Hi.

    To use Vertices, you must be a expert in casting...

    This is a sample in C# but you can try to convert this code. I use this code to find distance between a Location object and Vertices (from AddDrivetimeZone method)

    double dblMaxDistance = 0;
    foreach(object obj in ((object[])objShape.Vertices))
    {
    double dblDistance = ((MapPoint.Location)obj).DistanceTo(objLoc);
    if (dblDistance > dblMaxDistance) dblMaxDistance = dblDistance;
    }


    I hope this code help you.

  3. #3
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Vertices - Thanks...

    hi "Guest",

    well it doesnt require an expert !!
    and it sure did help !!!
    thank you !!!!

    anyway, didnt thought to cast to an object, after all the vertices are an array of locations...

    As i looked for a solution for this problem i saw lots of developers stuck on it - your solution is a salvation for a lot of people....

    keep on doing what ever you up to,

    Alon

  4. #4
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60

    Re: Vertices and VB.Net

    I don't think the above code works very well or not with later versions of MapPoint.
    C# it is fairly simple but with VB.NET you have to cast the Location array (vertices) into an Object array, and then cast each individual object into a Location, eg.

    Code:
    For Each obj As Object In CType(oShp.Vertices, Object())
    
           Dim loc As MapPoint.Location = CType(obj, MapPoint.Location)
         
           DoSomethingUseful( loc.Longitude, loc.Latitude )
    next
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to get the Locations for the 4 vertices of a Square?
    By cx123 in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 10-26-2004, 11:01 AM
  2. How to determine the length of Shape.vertices in Delphi?
    By schuchhardp in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 12-13-2002, 05:45 AM
  3. Zip codes or cities vertices or shapes
    By Claude VERDIER in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 09-17-2002, 06:21 AM

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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96