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 4 of 4

Getting Information Back from MapPoint

This is a discussion on Getting Information Back from MapPoint within the MapPoint Desktop Discussion forums, part of the Map Forums category; I have several polygons displayed on a MapPoint map. I am creating pushpins for various locations that are displayed on ...

  1. #1
    mwmcneil is offline Junior Member White Belt
    Join Date
    Oct 2007
    Posts
    2

    Getting Information Back from MapPoint

    I have several polygons displayed on a MapPoint map. I am creating pushpins for various locations that are displayed on the map. Is there a way to get information back (preferably into Access) as to what polygon a particular address is within? Or even a list of pushpins that are within a particular polygon.

    Thanks

  2. #2
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: Getting Information Back from MapPoint

    Hi! Welcome to the forum. I hope you find it useful and stick around.

    You can select a polygon and then right click on it and "Export To Excel" the list of pushpins within it... you could then import the lists to Access.

    If you are programming it, you can use the QueryShape or QueryPolygon method to get a recordset and loop through it and write back to Access.. see the Help File for more info on the Query methods and example code.

    e.g. for QueryPolygon

    Code:
    Sub QueryRecordsInBoxAtCenterOfMap()
        Dim objApp As New MapPoint.Application
        Dim objMap As MapPoint.Map
        Dim objDataSet As MapPoint.DataSet
        Dim objRecords As MapPoint.Recordset
        Dim objLocs(1 To 5) As MapPoint.Location
        Dim lngCount As Long
        
        'Set up application and objects to use
        Set objMap = objApp.ActiveMap
        lngCount = 0
        'create a "square" of locations in the middle of the map
        objMap.Altitude = objMap.Altitude / 2
        Set objLocs(1) = objMap.XYToLocation(0, 0)
        Set objLocs(2) = objMap.XYToLocation(objMap.Width, 0)
        Set objLocs(3) = objMap.XYToLocation(objMap.Width, objMap.Height)
        Set objLocs(4) = objMap.XYToLocation(0, objMap.Height)
        Set objLocs(5) = objMap.XYToLocation(0, 0)
        objMap.Altitude = objMap.Altitude * 2
        
        objApp.Visible = True
        objApp.UserControl = True
        
        'Remove the comment from the next line to see the polygon being queried
        'objMap.Shapes.AddPolyline objLocs
        
        'Let user create a data map
        Set objDataSet = objApp.ActiveMap.DataSets.ShowImportWizard
    
        'Find records in polygon
        Set objRecords = objDataSet.QueryPolygon(objLocs)
        objRecords.MoveFirst
        Do While Not objRecords.EOF
            lngCount = lngCount + 1
            objRecords.MoveNext
        Loop
        MsgBox "Number of records in polygon: " & lngCount
    End Sub
    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

  3. #3
    mwmcneil is offline Junior Member White Belt
    Join Date
    Oct 2007
    Posts
    2

    Re: Getting Information Back from MapPoint

    Thanks for the reply. I am currently doing the export to Excel and have the Excel file linked to the Access database but that is a little cumbersome for the end user. Also, the data exported to Excel does not contain the polygon information, so I have to manually export to Excel for each polygon.

    I have used the help file and the sample code and I can query a polygon to get a count of how many records are within that polygon, but I want to know exactly what records they are. Here is what I want to do:

    I have an Access table that has addresses where crime shave occurred. I have a MapPoint map that has polygons that represent political boundaries. I can plot the crime locations on the map and query the map to see how many crimes occurred in a specific polygon. I want to be able to create code that will query the polygons to get a list of the crimes that are in that polygon so I can store the polygon information with the crime data in Access. This will allow me to prepare crime statistics for each polygon.

    Thanks

  4. #4
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: Getting Information Back from MapPoint

    This is the part that loops through each one..

    Code:
        objRecords.MoveFirst
        Do While Not objRecords.EOF
            lngCount = lngCount + 1
            objRecords.MoveNext
        Loop
    As written all the code does is get the count, but you could access the location information from the objRecords recordset object.. I think use the Pushpin property e.g.

    Code:
      'Access the first Pushpin
      MsgBox objRS.Pushpin.Name
      objRS.Pushpin.Location.GoTo
    If you want help with the coding, there are probably some people in here who would be happy to do some consulting..

    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Atlas Is Back
    By smiller in forum News and Announcements
    Replies: 0
    Last Post: 07-25-2006, 03:59 PM
  2. Data2Map is back!
    By dkrafcheck in forum News and Announcements
    Replies: 0
    Last Post: 05-15-2006, 10:11 AM
  3. MapPoint information
    By law in forum Bing Maps and MapPoint Web Service
    Replies: 1
    Last Post: 06-14-2005, 06:12 PM
  4. Delphi/Mappoint - Modal Form looses Focus & sent to back
    By PinnacleDev in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 12-06-2004, 11:35 AM
  5. lat lon conversion from mappoint format back to gps sentence
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 09-10-2002, 01:42 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 84 85 86 87 88 89 90 91 92 93 94 95 96