Community of MapPoint and Virtual Earth Users and Developers
This is a discussion on Is it possible to retrieve county names from the z.... within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Is it possible to retrieve county names from the zip code/ or location object with a com addin? Thanks, Kevin...
| |||||||
| Today's Posts | Twitter Feed | Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
|
No. The county information is not exposed anywhere in the data model as a property. - Walt Cygan Update: 12/23/2001 - The following message posted on the microsoft.public.mappoint newsgroup may help you. Ken, On Sat, 22 Dec 2001 07:35:03 -0600, "Ken Levy" <kenlevy_deleteSpAm@home.com> wrote: >Gilles: > >Thanks for the post. I checked out the reference you gave and found several >good leads. One of the best, I think, was a dataset from the National >Weather Service which contains time zone for each county in the US. Is >there a way of getting the county name for a particular MP location object? Try this (put it into a VB module): Option Explicit Public Function CountyFromLocation(oMap As MapPoint.Map, _ oOrgLoc As MapPoint.Location) As String Dim oResults As MapPoint.FindResults ' Search for info Set oResults = oMap.ObjectsFromPoint( _ oMap.LocationToX(oOrgLoc), _ oMap.LocationToY(oOrgLoc)) ' define a generic object to iterate over FindResults Dim oObj As Object Dim oLoc As MapPoint.Location CountyFromLocation = "" ' Loop over collection For Each oObj In oResults ' Find out object type If TypeOf oObj Is MapPoint.Location Then Set oLoc = oObj ' Use Location object ' Got a county ? If oLoc.Type = geoShowByRegion2 Then CountyFromLocation = oLoc.Name Exit Function End If End If Next oObj End Function CountyFromLocation will return the name of the corresponding county, given a map object, and a location. It will return an empty string ("") if no county was found. Put the following into the code part of a VB form to test it: Option Explicit Dim oMpApp As MapPoint.Application Dim WithEvents oMap As MapPoint.Map Private Sub Form_Load() Set oMpApp = GetObject(, "MapPoint.Application") Set oMap = oMpApp.ActiveMap End Sub Private Sub oMap_BeforeClick(ByVal Button As Long, ByVal Shift As Long, ByVal X As Long, ByVal Y As Long, Cancel As Boolean) Dim oLoc As MapPoint.Location Set oLoc = oMap.XYToLocation(X, Y) Dim strCounty As String strCounty = CountyFromLocation(oMap, oLoc) If strCounty = "" Then strCounty = "No county found" List1.AddItem strCounty End Sub The form should have a listbox List1 - each time you click in the map (MapPoint should be running before you launch the program), it will display its county guess in the listbox. Regards, Gilles [MVP]. P.S.: You may also want to check out <http://www.mp2kmag.com/articles.asp?ArticleID=45> in this context - this was used as the basis for the above. --- Thanks, Gilles |
![]() |
| Tags |
| county, names, retrieve |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Retrieve Lat/Lon of a ShaddedCircle | rorgmanche | MapPoint 2006/2009 Discussion | 2 | 09-09-2005 07:38 AM |
| Showing only county lines and names? | Anonymous | MapPoint 2006/2009 Discussion | 2 | 02-10-2005 02:13 PM |
| Retrieve street names within shape | Dazzer | MapPoint 2006/2009 Discussion | 0 | 12-19-2003 04:52 AM |
| Adding county names and exporting | Anonymous | MapPoint 2006/2009 Discussion | 0 | 11-05-2003 05:00 PM |
| Also, can I delete the state names and city names .... | Anonymous | MapPoint 2006/2009 Discussion | 1 | 08-29-2000 12:57 PM |
Thassos Holidays
Visit an unspoilt and beautiful Greek island with Thassos holidays available through UlookUbook.