Community of MapPoint and Virtual Earth Users and Developers
This is a discussion on Location & FindResults not always returning City/State/etc.? within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; OK. I hope that I'm just doing something wrong. I've got some code for getting the center point of the ...
| |||||||
| Today's Posts | Twitter Feed | Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| 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
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. Last edited by OOT; 05-07-2008 at 02:13 PM.. Reason: Answered! |
| |||
| Re: Location & FindResults not always returning City/State/etc.?
Hi, sometimes there is no result you say, but indeed possible there is just no valid location in the center of the map. you can increase altitude to find one, increasing altitude set the dilusion of precision higher so chance is better there is a valid location.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
|
Wow. That was fast and it fixed the problem. So I've written it as a Function and if it returns as Nothing then I re-run at higher Altitude ... works like a charm! Thank you very much for that. |
| |||
| Re: Location & FindResults not always returning City/State/etc.?
Hi, Glad it works
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| city or state or etc, findresults, location, returning |
| ||||
| Posted By | For | Type | Date | |
| The Magazine for MapPoint - MP2K Magazine | This thread | Refback | 05-07-2008 05:52 PM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Return County for City-State Pairs | FrankB | MapPoint 2006/2009 Discussion | 0 | 09-06-2007 06:31 PM |
| How do you find the territory for a given city and state | UncleJaz | MapPoint 2006/2009 Discussion | 0 | 04-05-2006 10:50 AM |
| Removing City and State Names from a data map | klkrueg | MapPoint 2006/2009 Discussion | 1 | 06-07-2005 05:59 AM |
| Validating City/State Names | jbendiner | MapPoint 2006/2009 Discussion | 2 | 08-06-2004 02:33 PM |
| City, State and Country info for a loc found using lat/lng | lavend | MapPoint 2006/2009 Discussion | 0 | 04-28-2004 02:17 PM |
Algarve Holiday
Portuguese all year round sunshine is some of what awaits you if you choose the Algarve holiday option through UlookUbook!