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

## 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. 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. 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&#40;sa.Left, sa.Top&#41;
CalcPos&#40;objmap, objloc, 1&#41;
objloc = objmap.XYToLocation&#40;sa.Left + sa.Width, sa.Top + sa.Height&#41;
CalcPos&#40;objmap, objloc, 2&#41;
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. 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?

4. 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. 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?

6. 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&#40;"C&#58;\mymapname.ptm"&#41;
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. Senior Member Black Belt
Join Date
Jul 2002
Posts
5,137
Just what I needed. Thanks.

8. I don't know why I overlooked that one. Thanks for your help. I got it working now.

9. Member Yellow Belt
Join Date
Sep 2003
Posts
44

##### Users Browsing this Thread

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

#### Posting Permissions

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