Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 2 of 2

Is it possible to retrieve county names from the z....

This is a discussion on Is it possible to retrieve county names from the z.... within the MapPoint Desktop 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...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Is it possible to retrieve county names from the zip code/ or location object with a com addin?
    Thanks, Kevin

  2. #2
    Walt Cygan is offline Senior Member Green Belt
    Join Date
    Aug 2002
    Posts
    124
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Retrieve Lat/Lon of a ShaddedCircle
    By rorgmanche in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 09-09-2005, 07:38 AM
  2. Showing only county lines and names?
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 02-10-2005, 02:13 PM
  3. Retrieve street names within shape
    By Dazzer in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 12-19-2003, 04:52 AM
  4. Adding county names and exporting
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 11-05-2003, 05:00 PM
  5. Also, can I delete the state names and city names ....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 08-29-2000, 12:57 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83