C# .NET中的MapPoint 2011 FindAddress对话框

C# .NET中的MapPoint 2011 FindAddress对话框,c#,.net,mappoint,C#,.net,Mappoint,我正在使用C向Mappoint添加地址列表 foreach (Stop stop in _stops) _route.Waypoints.Add(_mpMap.FindAddressResults(stop.Street, stop.City, "", "Oregon", stop.Zip)[1]); 有时地址格式是错误的,正因为如此,我要么得到崩溃或完整的错误地址 在mappoint应用程序中,您可以搜索位置,如果mappoint发现多个位置或您的地址出错,它

我正在使用C向Mappoint添加地址列表

foreach (Stop stop in _stops)
                _route.Waypoints.Add(_mpMap.FindAddressResults(stop.Street, stop.City, "", "Oregon", stop.Zip)[1]);
有时地址格式是错误的,正因为如此,我要么得到崩溃或完整的错误地址

在mappoint应用程序中,您可以搜索位置,如果mappoint发现多个位置或您的地址出错,它将打开一个查找,并为您提供搜索和/或添加地址的选项

例如:

请注意,输入的地址格式很差,但MapPoint很容易找到格式正常的完整地址。有时会有更多的结果,如果出现这种情况,我需要能够手动选择。问题:怎么做

稍后添加:

我可以使用ShowFindDialog方法调用对话框本身,并且可以使用.count参数获得结果的计数

MapPoint.FindResults results = _mpMap.FindAddressResults(stop.Street, stop.City, "", "Oregon", stop.Zip);
MessageBox.Show("Found " + results.Count + " results");

但是我找不到指定地址的方法来显示FindDialog

您正在滥用FindAddressResults。这不会返回一个简单的数组,而只是一个FindResults集合。 FindResults集合包含一个名为ResultsQuality的属性。这在MapPoint附带的帮助文件中有完整的文档记录,但在盲目假设集合包含一个或多个结果之前,必须检查此值

ResultsQuality属性设置为GeoFindResultsQuality枚举。您要检查geoAllResultsValid 0或geoFirstResultGood 1。其他值表示没有结果或结果不明确

以下是文档中的VB6示例:

Sub AddPushpinToGoodFindMatch()

Dim objApp As New MapPoint.Application
Dim objFR As MapPoint.FindResults

'Set up the application
objApp.Visible = True
objApp.UserControl = True

'Get a FindResults collection
Set objFR = objApp.ActiveMap.FindResults("Seattle")

'If the first result is a good match, then use it
If objFR.ResultsQuality = geoFirstResultGood Then
    objApp.ActiveMap.AddPushpin objFR.Item(1)
Else
    MsgBox "The first result was not a good match."
End If

End Sub
FindResults是一个旧方法,它返回相同的FindResults类,但是使用FindAddressResults通常是更好的选择

附录:由于这个普遍问题是一个常见的问题,可能是因为MapPoint文档中的错误示例代码被盲目剪切和粘贴,所以我在MapPoint HowTo页面上写了一篇关于的文章