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

Getting Lat and long area from user's selection

This is a discussion on Getting Lat and long area from user's selection within the MapPoint Desktop Discussion forums, part of the Map Forums category; I am using the mappoint ActiveX control in a VB app. I want to get a range of lat and ...

  1. #1
    dew1969 is offline Junior Member White Belt
    Join Date
    Jan 2004
    Posts
    2

    Getting Lat and long area from user's selection

    I am using the mappoint ActiveX control in a VB app. I want to get a range of lat and long based on what area the user selects.

    I can get the objMap.SelectedArea and I can check for pushpins, select pushpins etc but I can't get the lat and long of the selected area.

    I can get the top, left, width, height of the selected area in relation to the active map but that is a far cry from getting the lat/long.

    Does anyone know of a calculation I can use?

    Thanks

  2. #2
    Matrices is offline Member Yellow Belt
    Join Date
    Sep 2003
    Posts
    44
    Here's what I use to do that
    Code:
    Dim sa As MapPoint.SelectedArea
            Dim dbllat As Double
            Dim dbllon As Double
            sa = objmap.SelectedArea
    
            objloc = objmap.XYToLocation(sa.Left, sa.Top)
            CalcPos(objmap, objloc, 1)
            objloc = objmap.XYToLocation(sa.Left + sa.Width, sa.Top + sa.Height)
            CalcPos(objmap, objloc, 2)
    It gets the top left of the square, assigns it to a location object and then uses the code in the article below to obtain the long and lat, then does it again for the bottom right corner (got by taking the left and adding the width to it and the top and adding the height, I know in theory you should subtract the height from the top but heh it works!! )

    http://www.mp2kmag.com/articles.asp?...xtract.lat.lon

    M

  3. #3
    Bug's Avatar
    Bug
    Bug is offline Junior Member White Belt
    Join Date
    Feb 2004
    Posts
    6
    I'm using a AxMappoint.AxMappointControl in my VB.NET project, and I don't get the "SelectedArea" option on my control. How can I get the selected area from an ActiveX control?
    Best Regards.
    Bug
    Microsoft Certified Solutions Developer

  4. #4
    Matrices is offline Member Yellow Belt
    Join Date
    Sep 2003
    Posts
    44
    you won't get it as axmappointcontrol1.selectedarea, you have to declare a mappoint object, like objmap in my example above and its part of that



    M

  5. #5
    Bug's Avatar
    Bug
    Bug is offline Junior Member White Belt
    Join Date
    Feb 2004
    Posts
    6
    Well, I already have an ActiveX control on my form, so declaring a new mappoint control dosen't really help. I have tried to declare a mappoint.mappoint control and assign it to my ActiveX control, but i get an "Invalid cast" error. So apperently I can't use that interface with the ActiveX control. So I'm wondering how to get the selected area then? Am I overlooking something?
    Best Regards.
    Bug
    Microsoft Certified Solutions Developer

  6. #6
    Matrices is offline Member Yellow Belt
    Join Date
    Sep 2003
    Posts
    44
    OK, now I'm back doing some coding work I'll show you exactly instead of from my note book

    Code:
    Dim objmap As MapPoint.Map
    I normally dothat in the globals at the start, just in case

    Code:
    Me.AxMappointControl1.NewMap("C:\mymapname.ptm")
    objmap = AxMappointControl1.ActiveMap
    And thats in form.load

    Once you've declared objmap as a mappoint object and assigned it to the active map of your control, selectedarea will be a control you can selet from it

    M

  7. #7
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Just what I needed. Thanks.

  8. #8
    Bug's Avatar
    Bug
    Bug is offline Junior Member White Belt
    Join Date
    Feb 2004
    Posts
    6
    I don't know why I overlooked that one. Thanks for your help. I got it working now.
    Best Regards.
    Bug
    Microsoft Certified Solutions Developer

  9. #9
    Matrices is offline Member Yellow Belt
    Join Date
    Sep 2003
    Posts
    44

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Pushpin Selection
    By EdB in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 08-14-2005, 09:25 AM
  2. Getting dataset from user selection
    By mic6399 in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 09-23-2004, 10:59 AM
  3. Zoom to selection?
    By sthurlock in forum MapPoint Desktop Discussion
    Replies: 6
    Last Post: 12-10-2003, 06:53 PM
  4. [Multi pushpins selection ?]
    By Vincent BENNER in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 01-30-2003, 04:41 AM
  5. Identifying Selection with Mouse
    By MapPointJim in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 08-20-2002, 04:39 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