OK. I hope that I'm just doing something wrong. I've got some code for getting the center point of the map (.width - 6 / 2, .height - 6 / 2). That returns a MapPoint.Location object.
I take that object and I just want to get some "general" location information (from the StreetAddress field). I don't care about the Address information but I do want to know the city, state and postal code for whatever location is the current centerpoint of the map. Here is what I've got and I can't figure out what I'm doing wrong.
Code:
''''oMPLoc is a MapPoint.Location set to these coordinates:
''''lat:33.3720721397549 lng: -83.7399965710938
oMPLoc.GoTo()
Dim addressResults As MapPoint.FindResults = _
oMap.ObjectsFromPoint(oMap.LocationToX(oMPLoc), _
oMap.LocationToY(oMPLoc))
Dim o As Object
For Each o In addressResults
If TypeOf o Is MapPoint.Location Then
Dim streetLoc As MapPoint.Location = o
If streetLoc.StreetAddress IsNot Nothing Then
txtCity.Text = streetLoc.StreetAddress.City
txtPostal.Text = streetLoc.StreetAddress.PostalCode
txtState.Text = streetLoc.StreetAddress.Region
End If
End If
Next Sometimes I run this and I get the information like I should but then sometimes I run it and everything is empty. When I debug and step through the code the StreetAddress object is either empty or contains empty strings for City, Region (State) and PostalCode.
Assuming I have a location based on valid Latitude and Longitude coordinates, is there a better way to get the City, State and PostalCode information? Can anyone see what I'm doing wrong in the code above (VB.NET)?
Any and all help is greatly appreciated. And please speak as plainly as possible as I'm quite the newbie
Thank you in advance for any and all help.