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

## How-to set map location to make set of points visisble

This is a discussion on How-to set map location to make set of points visisble within the MapPoint Desktop Discussion forums, part of the Map Forums category; I am using the MapPoint 2002 control in a Visual Basic application. I have a problem which I can't seem ...

1. Senior Member Black Belt
Join Date
Jul 2002
Posts
5,137

## How-to set map location to make set of points visisble

I am using the MapPoint 2002 control in a Visual Basic application. I have a problem which I can't seem to figure out. I've got a set of geographic locations ( lats/lons ) and I am trying to figure out how I can calculate the best location to set the map object's location to ( lat, lon and altitude ) so that all of these points are visible on the screen. The altitude should be the lowest possible altitude were all the points are visible.

The map is using the orthographic projection ( m_oMap.Projection = geoGlobeViewWhenZoomedOut ) but all my points are within North America so there is never a concern about a point being on the other side of the globe.

Also, the aspect ratio of the map is not fixed. If the aspect ratio was fixed, I could come up with a suitable solution.

Does anybody know of an algorithm I can use to solve this problem. My best (not very good) method right now is to calculate the range of coordinates of all these points and use the center of the bounding box of these points as my map location and then estimate the best altitude. My problem is that sometimes my altitude is far higher than it needs to be.

Thanks for any assitance.

2. Member Yellow Belt
Join Date
Feb 2003
Posts
48
You could use the datasets ZoomTo method and let MP do the thinking:

objMap.DataSets("My Pushpins").ZoomTo

M.

3. Senior Member Black Belt
Join Date
Jul 2002
Posts
5,137
Thanks Mossoft but I am not working with DataSets. I am strictly working with Lats/Lons. Unless there is a way to create a dataset programically which is not displayed on the map then I can use this method. I've looked into that and to me it doesn't look like I can do that.

Thanks again.

4. Senior Member Black Belt
Join Date
Jul 2002
Posts
5,137

## How-to set map location to make set of points visisble

Have you tried using the GetLocation method to get an object location for each set of Lat/Lon coordinates then using the Union method with the array of object locations.

Set objLoc1 = objMap.GetLocation(Lat1, Lon1)
Set objLoc2 = objMap.GetLocation(Lat2, Lon2)
etc.

objMap.Union(Array(objLoc1, objLoc2)).GoTo

Presumably this can be extended to cover more locations

objMap.Union(Array(objLoc1, objLoc2, ---- etc. )).GoTo

Quote from the Union Method:

"Returns a Location object that represents the best map view to display all of the specified locations."

RVH.

5. Senior Member Black Belt
Join Date
Jul 2002
Posts
5,137
Thanks a lot RVH, that certainly seems to work quite well. I haven't tested it out in terms of performance over time with many points but I think this may be the answer.

6. Senior Member Black Belt
Join Date
Jul 2002
Posts
5,137

7. Junior Member White Belt
Join Date
May 2004
Posts
9
In case this is useful to you. I just posted some information about calculating altitude based on a circular area/radius around a location.

The information can be found at:

http://www.mp2kmag.com/mappoint/disc...?p=10457#10457

Basically I determined that:

objMap.Altitude = Round(radius + (radius * 3.25))

Don't ask.. I have a lot of free time.. sometimes. hah.

Sounds like you pretty much got your issue figured out and if you used this, you'd still have to figure out the radius to use, but more information is better than not enough eh?

Good luck!

-TG

##### 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
•