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

Coordinates to a rectangle

This is a discussion on Coordinates to a rectangle within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hello all, I have another itch. I want to place a rectangle shape on a map and afterwords get te ...

  1. #1
    Jamboo is offline Junior Member White Belt
    Join Date
    Jul 2008
    Posts
    7

    Cool Coordinates to a rectangle

    Hello all, I have another itch.

    I want to place a rectangle shape on a map and afterwords get te coordinates for the TopLeft corner and the BottomRight one since my code handles these coordinates rather than the location width and hight.
    I have no problem drawing the rectangle it is with the coordinates where I am stuck Ihave seen the vertices property in the shape namespace but it returns an object type and I have done some testing but cant make any sesnce.

    Any sugestions?.
    thanks

  2. #2
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: Coordinates to a rectangle

    I'm not sure I understand the issue but here's some information..

    Vertices is an array of Location objects.. see the Vertices Property in the Help File... here is the example code:

    Code:
      Sub CreateTwoShapes()
     
      Dim objApp As New MapPoint.Application
      Dim objMap As MapPoint.Map
      Dim objLoc(1 To 3) As MapPoint.Location
     
      'Set up the application
      Set objMap = objApp.ActiveMap
      objApp.Visible = True
      objApp.UserControl = True
     
      'Get three locations and zoom in, and then create a shape
      Set objLoc(1) = objMap.FindResults("Seattle, WA").Item(1)
      Set objLoc(2) = objMap.FindResults("Redmond, WA").Item(1)
      Set objLoc(3) = objMap.FindResults("Tacoma, WA").Item(1)
      Set objMap.Location = objLoc(1)
      objMap.Shapes.AddPolyline objLoc
     
      'Use the vertices of this shape to create another shape
      objMap.Shapes.AddPolyline objMap.Shapes.Item(1).Vertices
      MsgBox "There are now " + CStr(objMap.Shapes.Count) + " shapes."
     
      End Sub
    To get at the location items, Lat/Lon's, I think the syntax would be like this:

    objMap.Shapes.Item(1).Vertices(1).Longitude
    objMap.Shapes.Item(1).Vertices(1).Latitude
    objMap.Shapes.Item(1).Vertices(2).Longitude
    ....

    What language are you coding in?

    Erc
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

  3. #3
    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: Coordinates to a rectangle

    The rectangle object (rather than a freeform like I think Eric is describing) is defined in terms of width and height. Unfortunately the exact way this maps to the Earth's surface depends on your current map view. It will change!

    My solution is to extrapolate from the centre coordinate and accept that it might not quite match at the edges/corners all the time. Another solution would be to play with screen coordinates. This would more accurately match the on-screen representation although it would rely on the rectangle being fully on the screen all the time.


    Also because the Earth is a sphere, you need multiple points on each edge to get a decent representation. I find 3 or 4 (rather than 2: 1 per corner) works pretty well.

    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  4. #4
    Jamboo is offline Junior Member White Belt
    Join Date
    Jul 2008
    Posts
    7

    Smile Re: Coordinates to a rectangle

    Sorry Eric, for the delay I have been traveling,

    thanks for the answer, but what I need is to draw a shape on the map a rectangle not using a collection of locations. The user will draw the shape with the map point drawing tool.

    once the shape is drawn I need to get the vertices, as I have tested them before if the shape vertices do not meet with any other object in the dataset I get no information on the vertices. on your example you actualy define the vertices form locations or places, but I have none of this

    I need to store the upper left corner and the bottom right corner, I use this information on a GPS Tracking device that uses it as a POI or GeoFence reference.

    I was thinking in using a little math with some help from pitagoras and the circle law but I was wondering if anybody had a snippet to reuse and avoid reworking known algorithms.

    I am currentlly coding in VB.Net on VS 2008 but anithing in C, C++ or C# will be ok.


    Brgds
    Ian.

    PS. I got the a note from the post office so I guess it will be the book I ordered.

  5. #5
    Jamboo is offline Junior Member White Belt
    Join Date
    Jul 2008
    Posts
    7

    Thumbs up Re: Coordinates to a rectangle

    Thank Richard,

    I will have a try at the screen points since my rectangle has to be completey in the screen when the cilent has finished drawing it. thanks for the tip. seems easyer to do than all the other maths.

    Wonder why MS dosent pull the Lat/Lon for every object or object vertice on the map ?? as you say it is only drawing logic.

    brgds
    Ian.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Lat/Lons of the Corners of a Rectangle Object
    By Eric Frost in forum MapPoint Desktop Discussion
    Replies: 6
    Last Post: 04-09-2008, 09:50 AM
  2. How to draw a rectangle with text in it?
    By VC_Man in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 12-12-2006, 05:54 AM
  3. how to calculate Lat/Longs for the corners of a rectangle?
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 01-29-2005, 05:18 AM
  4. Get all pushpins in a shape (Radius, Rectangle ...)
    By kobkob in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 04-18-2004, 05:44 AM
  5. Values of area in rectangle
    By Matrices in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-13-2003, 01:16 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 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127