Hey mbdunkin
I do not know if this is the most beautiful approach but this is what I'd do:
'Get some unclear results and add a pushpin
Set objPin = myobj.ShowFindDialog("4950 Hamilton Ave, , California", geoFindAddress)
'use the pushpin to get a Location Object
set oLocA = objPin.Location
Then use a version of the code provided by Chris @ Crime Analysis.net in this article:
http://www.mp2kmag.com/a9--gebhardt.....mappoint.html
Change the Subroutine parameter from string of address to a MapPoint.Location.
Sorry all this is in VB6 but a smart C# guy like you will figure it out.
Here's my/Chris's test code hacked out to see if it works.
<pre>
Sub GetLatLong()
'Latitude/Longitude Discovery Module (v1.0, June 5, 2001)
'Created by Christopher S. Gebhardt Chris @ Crime Analysis.net
' Crime Analysis Associates
www.CrimeAnalysis.net
'This code is hereby released into the public domain. Please forward any suggestions
'or additions to the author. If you decide to use this code snippet, leave this
'header information intact to give credit to the author!
'MOD: Terry Calvin FleetScan Solutions
www.fleetscan.com
' 15-Aug-2005
' Converted version to work off of a location object.
Dim oPush, oPushA As MapPoint.Pushpin
Dim oLoc, oLocA, oLocB As MapPoint.Location
Dim PointX, PointY As MapPoint.Location
Dim measure, percision As Double
Dim zLat, zLong, DistX, DistY, DistZ As Double
Dim myapp As New MapPoint.Application
Dim myobj As MapPoint.Map
Dim objPin As MapPoint.Pushpin
'Set up the application
' wk_istat2 = Open_Map("C:\Documents and Settings\Terry58\My Documents\test.ptm")
Set myobj = myapp.ActiveMap
myapp.Visible = True
myapp.UserControl = True
'Get some unclear resutls
Set objPin = myobj.ShowFindDialog("4950 Hamilton Ave, , California", geoFindAddress)
'myLat and myLong are a known point. In this case, Wichita, Kansas
myLat = 37.70212
myLong = -97.31775
'Initially, set zLat and zLong equal to the known point
zLat = myLat
zLong = myLong
'Measure is used to adjust the starting distance. In this case, start off with 750 miles.
'Measure is made smaller in the Do While loop below but it is a good idea to start off
'with a large number
'A Mile = 0.01471 Degrees of Lat/Long, a Half mile = 0.007355
measure = 0.01471 * 750
'Percision of 20ft
percision = (0.01471 / 5280) * 20
'Create two points: oLoc as the reference point and oLocA your address for which you need lat/long
'In a real work example pass objPin.Location into the subroutine as a Location Object
Set oLoc = myobj.GetLocation(myLat, myLong)
Set oLocA = objPin.Location
X = 0
'Create a loop that will continue until your desired precision. As indicated below
'this loop will repeat until the lat/long is found to be within 20 feet.
Do While measure > percision
X = X + 1
'Create two other reference points: PointX is one Measure off oLoc's Lattitude
' PointY is one Measure off oLoc's Longitude
Set PointX = myobj.GetLocation(zLat + measure, zLong)
Set PointY = myobj.GetLocation(zLat, zLong + measure)
'Measure the distances from each of the three reference points to our main address (oLocA)
DistX = oLocA.DistanceTo(PointX)
DistY = oLocA.DistanceTo(PointY)
DistZ = oLocA.DistanceTo(oLoc)
'Determine which reference point is closer to oLocA, our main address
If DistX < DistY And DistX < DistZ Then
'Make the master reference point oLoc equal to PointX since PointX was the closest to
'our main address
Set oLoc = myobj.GetLocation(zLat + measure, zLong)
zLat = zLat + measure 'Don't forget to add the Measure to zLat for the next iteration
End If
If DistY < DistX And DistY < DistZ Then
Set oLoc = myobj.GetLocation(zLat, zLong + measure)
zLong = zLong + measure
End If
If DistZ < DistX And DistZ < DistY Then
'The main reference point is closer than PointX or PointY.
'PointX and PointY were too far away by ADDING a Measure, so here we need
'to subtract a measure from both the Latitude and the Longitude
Set oLoc = myobj.GetLocation(zLat - measure, zLong - measure)
zLat = zLat - measure
zLong = zLong - measure
End If
'Here is where Measure gets adjusted. Check to see if the distance between the new
'reference point is smaller than Measure. If so, reduce Measure by half.
'Don't forget that Measure is in degrees of Lat/Long while the distance will be
'in miles. To convert degrees to miles, multiply by .01471, the number of degrees
'in a mile.
If oLocA.DistanceTo(oLoc) < measure / 0.01471 Then
measure = measure / 2
End If
' Set oPush = myobj.addpushpin(myobj.GetLocation(zLat, zLong), "Point: " & Str(X))
' oPush.Location.Goto
' oPush.BalloonState = geoDisplayBalloon 'Turn on the balloon state so we can see the lat/long
' Debug.Print "Iteration is " & Str(X) & " and Measure is " & Str(measure)
Loop
'Create a PushPin with the new location that matches our address
'Add how many iterations of the loop it took (x) and the the Latitude, Longitude
Set oPush = myobj.addpushpin(oLoc, Str(X) & ": " & Str(zLat) & ", " & Str(zLong))
oPush.Location.Goto
Debug.Print "The Lat/Long of your address is " & zLat & ", " & zLong & _
Chr(13) & "It was found in " & X & " iterations."
'The next four lines are just for presentation. Uncomment them if you like
oPush.BalloonState = geoDisplayBalloon 'Turn on the balloon state so we can see the lat/long
oPush.Highlight = True 'Highlight the pushpin so we really see it
myobj.DataSets.ZoomTo 'Zoom the map to the individual pushpin
'myobj.Saved = True
End Sub
</pre>