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

Anonymous
01-16-2004, 09:44 AM
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.

Mossoft
01-16-2004, 10:15 AM
You could use the datasets ZoomTo method and let MP do the thinking:

objMap.DataSets("My Pushpins").ZoomTo


M.

Anonymous
01-16-2004, 04:14 PM
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.

Anonymous
01-19-2004, 02:26 PM
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.

Anonymous
01-19-2004, 03:05 PM
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.

Anonymous
01-20-2004, 11:59 AM
:) :o

Gryffyn
09-08-2004, 01:22 PM
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/discussion/viewtopic.asp?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

 
Web mp2kmag.com
mapforums.com