FindNearby method
Finds nearby places around a specified location, route, or route segment. Results are sorted in distance order, from closest to farthest, and are limited to the currently visible PlaceCategory objects. Returns a FindResults collection.
Applies to
Collections: Directions
Syntax
object.FindNearby(Distance)
Parameters
Part |
Description |
---|---|
object |
Required. An expression that returns a collection or object in the Applies to list. |
Distance |
Required Double. The distance to search, in GeoUnits. |
Remarks
The map view is changed to the best map view of the find results. To return to the map view that existed before the FindNearby method was used, use the GoBack method on a Map object.
To return or set GeoUnits, use the Units property of an Application or MappointControl object.
Example
[Microsoft Visual Basic 6.0]
Sub GetClosestPointOfInterest()
Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim objLoc As MapPoint.Location
'Set up application
Set objMap = objApp.ActiveMap
objApp.Visible = True
objApp.UserControl = True
'Get a location on the map
Set objLoc = objMap.FindResults("Seattle, WA").Item(1)
'Find nearby places 2 miles from that location
MsgBox "Closest nearby place: " + objLoc.FindNearby(2).Item(1).Name
End Sub
[C#]
void GetClosestPointOfInterest()
{
MapPoint.Application objApp = new MapPoint.Application();
MapPoint.Map objMap = null;
MapPoint.Location objLoc = null;
MapPoint.Location objLoc2 = null;
object key = 1;
//Set up application
objMap = objApp.ActiveMap;
objApp.Visible=true;
objApp.UserControl=true;
//Get a location on the map
objLoc = (MapPoint.Location) objMap.FindResults("Seattle, WA").get_Item(ref key);
//Find nearby places 2 miles from that location
objLoc2 = (MapPoint.Location) objLoc.FindNearby(2).get_Item(ref key);
//A reference to System.Windows.Forms.dll is needed to show the MessageBox
System.Windows.Forms.MessageBox.Show("Closest nearby place: " + objLoc2.Name.ToString());
}
Note This sample code is specifically for use in MapPoint North America; it is for illustration purposes only.