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

Export Latitude and Longitude

This is a discussion on Export Latitude and Longitude within the Products: Pushpin Tool, Single State Mapper forums, part of the Map Forums category; I'm using mappoint 2006. Is there any way to export the latitude and longitude info for my pushpins matched by ...

  1. #1
    dastephens is offline Junior Member White Belt
    Join Date
    Nov 2009
    Posts
    1

    Export Latitude and Longitude

    I'm using mappoint 2006. Is there any way to export the latitude and longitude info for my pushpins matched by street address?

  2. #2
    davidb is offline Senior Member Blue Belt
    Join Date
    Oct 2003
    Location
    London
    Posts
    290

    Re: Export Latitude and Longitude

    Two possibilities

    1. Invest in the excellent Pushpin Tool
    Pushpin Tool: Manage your Microsoft MapPoint Pushpins

    2. Run some excel vba code to export pushpin data, including latitude and longitude, into an excel worksheet. Here’s some basic code that runs on the active map that might help get you started....

    Code:
    Option Explicit
    
    Private Sub ExportLatLongs_Click()
    Dim objMap As MapPoint.Map
    Dim objDataSet As MapPoint.DataSet
    Dim objDataSets As MapPoint.DataSets
    Dim objRecordSet As MapPoint.Recordset
    Dim objFields As MapPoint.Fields
    Dim objField As MapPoint.Field
    Dim objPin As MapPoint.Pushpin
    Dim objLoc As MapPoint.Location
    Dim Ws1 As Excel.Worksheet
    Dim PushpinSet As String
    Dim NDataSets As Integer, kCount As Integer, i As Integer
    Dim Lat As Double, Lon As Double
    Dim booSetFound As Boolean
    
    On Error GoTo NoActiveMap
    'specify appropriate MapPoint version
    Set objMap = GetObject(, "MapPoint.Application.EU.16").ActiveMap
    On Error GoTo Error_handler
    
        Set Ws1 = Sheets("Sheet1")
        Ws1.UsedRange.Clear 'clear any old data
        
        Set objDataSets = objMap.DataSets
        NDataSets = objDataSets.Count
         If NDataSets = 0 Then
            GoTo NoDataSets
         Else
         End If
    '******************************************************************************
    ' Specify the pushpin set name you want the info exported for
    '******************************************************************************
        PushpinSet = "My pushpins"
        
        booSetFound = False
        For Each objDataSet In objDataSets
            If objDataSet.Name = PushpinSet Then
                booSetFound = True
                Set objRecordSet = objDataSet.QueryAllRecords
                kCount = 0
                objRecordSet.MoveFirst
                Set objFields = objRecordSet.Fields
                    For i = 1 To objRecordSet.Fields.Count
                        Ws1.Cells(1, i + 1) = objFields(i).Name
                    Next
                    Ws1.Cells(1, 1).Value = "Pushpin Name"
                    Ws1.Cells(1, objFields.Count + 2).Value = "Latitude"
                    Ws1.Cells(1, objFields.Count + 3).Value = "Longitude"
                 
                 Do Until objRecordSet.EOF
                     Set objFields = objRecordSet.Fields
                     kCount = kCount + 1
                                         
                       For i = 1 To objFields.Count
                          Ws1.Cells(kCount + 1, i + 1).Value = objFields(i).Value
                       Next i
    
                       Set objPin = objRecordSet.Pushpin
                       Set objLoc = objPin.Location
                       Lat = objLoc.Latitude 'Get latitude of this location
                       Lon = objLoc.Longitude 'Get longitude of this location
                       Ws1.Cells(kCount + 1, 1) = objPin.Name
                       Ws1.Cells(kCount + 1, objFields.Count + 2).Value = Round(Lat, 6)
                       Ws1.Cells(kCount + 1, objFields.Count + 3).Value = Round(Lon, 6)
                    objRecordSet.MoveNext
                  Loop
    
        Else
        End If
        Next
        
        If booSetFound = False Then
            GoTo NoPushpinSet
        Else
        End If
        
        MsgBox "Data for " & kCount & _
                " pushpins in data set '" & PushpinSet & _
                "' exported to excel worksheet."
    
    GoTo Exit_handler
    
    NoActiveMap:
    MsgBox "This program works on an active MapPoint map." _
            & " You need to have a map open.", vbExclamation, _
            "Program Ending"
    GoTo Exit_handler
    
    NoDataSets:
    MsgBox "Sorry but there don't appear to be any datasets on this map.", _
           vbExclamation, "Program Ending"
    GoTo Exit_handler
    
    NoPushpinSet:
    MsgBox "There doesn't appear to be a pushpin set called " & PushpinSet & _
           " on this map.", vbExclamation, "Program Ending"
    GoTo Exit_handler
    
    Error_handler:
        MsgBox "Error " & Err.Number & vbCrLf & vbCrLf & _
                Err.Description, vbExclamation, "Program Ending"
                
    Exit_handler:
        Set objMap = Nothing
        Set objDataSet = Nothing
        Set objDataSets = Nothing
        Set objRecordSet = Nothing
        Set objField = Nothing
        Set objFields = Nothing
        Set objPin = Nothing
        Set objLoc = Nothing
        Set Ws1 = Nothing
    
    End Sub
    Hope that helps
    David
    UK mapping and map analysis services at www.broomanalysis.plus.com

  3. #3
    Conor is offline Junior Member Yellow Belt
    Join Date
    Jun 2010
    Posts
    17

    Re: Export Latitude and Longitude

    I know this is a bit late, but if you are looking for a freeware solution to your problem, I found one in the form of PROFIT100's program IC-DatasetExport. Unfortunately, the company is German, and I was unable to find an English version of the program. The program is very easy to work, however. Simply run the program, choose your pushpin dataset(s), and it exports wherever you want, complete with lat and long.

  4. #4
    PappyBlueRibs is offline Junior Member White Belt
    Join Date
    Jun 2011
    Posts
    1

    Re: Export Latitude and Longitude

    Davidb, thank you for your EXCELLENT solution!

    A few points, for anyone implementing this:
    1. This VBA code could go behind a button that you put onto an Excel spreadsheet.
    2. I changed Davidb's code
    Set objMap = GetObject(, "MapPoint.Application.EU.16").ActiveMap
    to fit my verson of MapPoint. For me, it is
    Set objMap = GetObject(, "MapPoint.Application.NA.17").ActiveMap
    because I'm using MapPoint North America 2010.
    3. For those of you new to VBA, when you are looking at your code, you might have to add the MapPoint reference to Excel. You'll do this in Microsoft Visual Basic by going to Tools/References and selecting "Microsoft MapPoint 17 Object Library" (or whatever version you are using).

    But Davidb, these are pointers for beginners, everything else was very good and very fast. Thanks!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. 0 latitude and 0 longitude
    By polynaux in forum Bing Maps and MapPoint Web Service
    Replies: 1
    Last Post: 07-26-2007, 10:16 AM
  2. Latitude and Longitude
    By virgilar in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 03-21-2005, 01:01 PM
  3. Latitude and Longitude
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-25-2003, 12:52 PM
  4. NMEA latitude/longitude and mappoint latitude/longitude
    By muurman in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 11-22-2003, 04:42 AM
  5. Export Latitude and Longitude information?
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 09-25-2002, 09:57 AM

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