Microsoft KB Archive/297348

= How To Display A Particular Radius with MapPoint =

Article ID: 297348

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition, when used with:
 * Microsoft MapPoint 2002 Standard Edition

-



This article was previously published under Q297348



SUMMARY
This article demonstrates how to use MapPoint to show a map that is zoomed to a certain distance around a particular point.



MORE INFORMATION
MapPoint is an Automation server, which means that other programs can control its behavior.

MapPoint controls the zoom factor with the Map.Altitude property, so it is necessary to convert the radius to the proper altitude. This value depends on the screen resolution and physical screen size.

The following code demonstrates how to display the area 3 miles around De Smet, SD: *!* Q297348 How To Display A Given Radius With MapPoint
 * !* This code displays a map that is zoomed so that it shows a particular radius
 * !* around a point. The Altitude property controls the zoom factor.
 * !* Different screen sizes and resolutions generate different values
 * !* for Altitude, but this code causes the correct area to
 * !* appear on any system.
 * !* appear on any system.


 * !* Conversion factor between miles and kilometers.
 * 1) DEFINE MILESTOKM 1.609


 * !* MapPoint constants.
 * 1) DEFINE geoKM 1
 * 2) DEFINE geoShapeRadius 1009

oApp = CREATEOBJECT(&quot;MapPoint.Application&quot;)

lnRadius = 3   && miles -- set to whatever value you want. lnKMRadius = lnRadius * MILESTOKM oApp.Units = geoKM  && set units to kilometers

oMap = oApp.ActiveMap WITH oMap oLoc = .FindResults(&quot;De Smet, South Dakota&quot;).Item(1).Location oPushpin = .AddPushpin(oLoc, &quot;Little Town on the Prairie&quot;) oLoc.GoTo

.Altitude = RadiusToAltitudeKM(lnKMRadius, oMap)

*!* This code displays a circle so that you can verify the display area. oCircle = .Shapes.AddShape(geoShapeRadius, oLoc, ;     (lnKMRadius * 2), (lnKMRadius * 2))

.Saved = .T. && Trick MapPoint into thinking it doesn't have to save. ENDWITH

oApp.Visible = .T.

MESSAGEBOX(&quot;Hit Enter to close MapPoint.&quot;, 0, &quot;Q297348&quot;)

IF TYPE(&quot;oApp.Name&quot;) = &quot;C&quot; oApp.Quit ENDif

FUNCTION RadiusToAltitudeKM LPARAMETERS tnKMRadius, toMap

lnScreenWidth = SYSMETRIC(1)  && Width in pixels lnScreenHeight = SYSMETRIC(2) && Height in pixels lnPhysicalWidth = 0.35 && meters: assumes 17&quot; monitor, which is 14&quot; wide lnPhysicalHeight = 0.2625

lnPercentW = lnScreenWidth / toMap.Width lnAltitudeW = lnPercentW * tnKMRadius / (2.5 * (lnPhysicalWidth / 2))

lnPercentH = lnScreenHeight / toMap.Height lnAltitudeH = lnPercentH * tnKMRadius / (2.5 * (lnPhysicalHeight / 2))

lnReturnAlt = IIF(lnAltitudeW > lnAltitudeH, lnAltitudeW, lnAltitudeH)

RETURN lnReturnAlt

