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
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Problems with Pushpin dataset

This is a discussion on Problems with Pushpin dataset within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi everyone, MapPoint 2002, VB6 I’m using the map to show live vehicle with, for each vehicle, a different pushpin ...

  1. #1
    Sylvain is offline Junior Member Yellow Belt
    Join Date
    Aug 2002
    Posts
    12

    Problems with Pushpin dataset

    Hi everyone,

    MapPoint 2002, VB6

    I’m using the map to show live vehicle with, for each vehicle, a different pushpin and each vehicle bellows to its own datasets. (Vehicle “Truck1”, with its bread crumps, is part of dataset “Truck1” with a different pushpin name for each of its bread crumps).

    Everything works fine until I use the “Find” command on the navigation toolbar, the “Find” form of MapPoint starts to blink and is not accessible.
    I trap the error “-2147418111 : Method 'DataSets' of object '_Map' failed”. If I click on the map or on VB, it gives me the famous “switch to” message.

    In the program, if I do a “resume next”, it’s doing the same. This error only occurs when I click the find and occurs with one or many live vehicle on the map. Is there anyway of trapping the click event on the “Find”? Any help/suggestions will be welcome.

    Sylvain

  2. #2
    Sylvain is offline Junior Member Yellow Belt
    Join Date
    Aug 2002
    Posts
    12
    Take two,

    I’ve change my code to use the “FindPushpPin” instead of “QueryAllRecords” and I still have the same problem with the “Find” of navigation toolbar with a similar error message.

    Sylvain

  3. #3
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    I think you will have to post the code behind your find button before we can help you debug it.

  4. #4
    Sylvain is offline Junior Member Yellow Belt
    Join Date
    Aug 2002
    Posts
    12
    Hi John,

    The code I use with the DataSet is:

    Set objRecordset = pubMap.DataSets(VehicleInfo(Index).VehicleNm).Quer yAllRecords

    and it the problem occurs on the "Set".

    I've change my code to use the the following
    Set objPushPin = pubMap.FindPushpin(VehicleInfo(Index).VehicleNm)

    and same thing happen on the 'Set'. The code works fine until I click on the 'Find' of the 'Navigation Toolbar'. I've also reinstall MapPoint and the same thing. I test it on 2 computers without a programming environment and the same error.

    Sylvain

  5. #5
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    Here are two samples. Lets say your Dataset was named Test and your pushpin was named Home.

    Dim objMap As MapPointctl.Map
    Set objMap = MappointControl1.ActiveMap
    Dim objDataSet As MapPointctl.DataSet
    Dim objRecords As MapPointctl.Recordset

    Set objDataSet = objMap.DataSets("Test")
    Set objRecordset = objDataSet.QueryAllRecords
    '//////////////////////////////////////////////////////
    Dim objPin As MapPointctl.Pushpin
    Set objPin = objMap.FindPushpin("Home")

  6. #6
    Sylvain is offline Junior Member Yellow Belt
    Join Date
    Aug 2002
    Posts
    12
    Hi John,

    Thank you for taking the time, I've changed the code to use the dataset again and used the following code:

    Dim objRecordset As MapPointctl.Recordset
    Dim objDataSet As MapPointctl.DataSet

    Set objDataSet = pubMap.DataSets(VehicleInfo(Index).VehicleNm)
    Set objRecordset = objDataSet.QueryAllRecords

    Again the same problem on the first 'set'. I'm sorry for repeating myself but this code works for hours without a problem and the only problem is when the 'Find' of the toolbar is used.

    I've added the following to look at the dataset, the proper name shows but again the same error occurs when I used the find. The error stop on the 'For'.

    For intCnt = 1 To pubMap.DataSets.Count
    Debug.Print pubMap.DataSets(intCnt).Name
    Next

    Sylvain

  7. #7
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    Sylvain,

    When you hit the "Find" button, what information are you passing to your code?

    What is VehicleNm? Is that a pushpin?

    In one of your posts you mentioned a dataset named "Truck1"
    If that is the name of a dataset on your map, you could use the following to set a reference to dataset "Truck1"

    Set objDataSet = pubMap.DataSets("Truck1")

    'This sample might help.

    Dim objMap As MapPointctl.Map
    Set objMap = MappointControl1.ActiveMap
    Dim objDataSet As MapPointctl.DataSet
    Dim objRecords As MapPointctl.Recordset


    Set objDataSet = objMap.DataSets("Truck1")
    Set objRecordset = objDataSet.QueryAllRecords

    Do While Not objRecordset.EOF
    Debug.Print objRecordset.Pushpin.Name
    objRecordset.MoveNext
    Loop

  8. #8
    Sylvain is offline Junior Member Yellow Belt
    Join Date
    Aug 2002
    Posts
    12
    Hi John,
    THis following code is a sub set of what I use. Just create a form, add 2 command button, a timer, and a mapcontrol. A lot of comments were removed to it smaller.

    The command1 starts the timer, the timer displays icons with 5 bread crumbs, click on the find of the toolbar and wait 5 seconds. (Please tell me you have the same error.)

    Thanks,
    Sylvain
    Code:
    Option Explicit
    
    Public pubMap As MapPointCtl.Map
    Public privPushPinName As String
    Public privRecCnt As Integer
    
    Public Sub subDataSetExist(ByVal pDataSetName As String)
        
        Dim boolDataSetFound As Boolean
        Dim intCnt As Integer
        boolDataSetFound = False
        For intCnt = 1 To pubMap.DataSets.Count
            If pubMap.DataSets(intCnt).Name = pDataSetName Then
                boolDataSetFound = True
                Exit For
            End If
        Next
        ' If the Data Set was not found, create the Data Set
        If Not boolDataSetFound Then
            pubMap.DataSets.AddPushpinSet pDataSetName
        End If
    
    End Sub
    
    
    Private Sub Command1_Click()
        privRecCnt = 0
        subDataSetExist privPushPinName
        Me.Timer1.Interval = 5000
        Me.Timer1.Enabled = True
    End Sub
    
    Private Sub Command2_Click()
        Me.Timer1.Enabled = False
        Me.Timer1.Interval = 0
    End Sub
    
    Private Sub Form_Load()
        privPushPinName = "Truck"
        Me.MappointControl1.NewMap (geoMapNorthAmerica)
        Set pubMap = Me.MappointControl1.ActiveMap
        pubMap.Application.Toolbars.Item("Navigation").Visible = True
    End Sub
    
    
    Private Sub Form_Unload(Cancel As Integer)
    
        If Not (pubMap Is Nothing) Then
            pubMap.Saved = True
            pubMap.Application.Quit
        End If
    
    End Sub
    
    
    Private Sub Timer1_Timer()
    
        Dim objLoc As MapPointCtl.Location
        Dim objPushPin As MapPointCtl.Pushpin
        Dim objRecordset As MapPointCtl.Recordset
        Dim objDataSet As MapPointCtl.DataSet
        Dim dblLatitude As Double
        Dim dblLongitude As Double
        Dim lngX As Long
        Dim lngY As Long
        Dim intBreadCrumbs As Integer
        Dim strTemp As String
    
        privRecCnt = privRecCnt + 1
        
        dblLatitude = CDbl(45.56868)
        dblLongitude = CDbl(-73.60147)
        
        ' Just to move the Icon
        dblLatitude = dblLatitude + CDbl(privRecCnt / 1000)
        dblLongitude = dblLongitude + CDbl(privRecCnt / 1000)
    
        ' Retrieve the Dataset for this vehicle
        Set objDataSet = pubMap.DataSets(privPushPinName)
        Set objPushPin = Nothing
        
        ' Use to query all the records
        Set objRecordset = objDataSet.QueryAllRecords
        
        ' Go to the first one, just in case...
        objRecordset.MoveFirst
        
        ' Retrieve the vehicle in the DataSet
        Do While Not objRecordset.EOF
            If objRecordset.Pushpin.Name = privPushPinName Then
                Set objPushPin = objRecordset.Pushpin
                Exit Do
            End If
            objRecordset.MoveNext
        Loop
        
        If Not (objPushPin Is Nothing) Then
            
            intBreadCrumbs = privRecCnt Mod 5
                
            ' Create a Unique Name for the Vehicle Push Pin
            strTemp = "Crumbs " & CStr(intBreadCrumbs) & " of " & privPushPinName
    
            objRecordset.MoveFirst
            Do While Not objRecordset.EOF
                ' The bread crumbs name was found
                If objRecordset.Pushpin.Name = strTemp Then
                    ' Delete this pushpin before changing the name of the original one
                    ' to that Bread Crumbs.
                    objRecordset.Pushpin.Delete
                    Exit Do
                End If
                objRecordset.MoveNext
            Loop
            
            objPushPin.Name = strTemp
            
        End If
    
        With pubMap
            Set objLoc = .GetLocation(dblLatitude, dblLongitude)
            ' Add the pushpin to the Original name.
            Set objPushPin = .AddPushpin(objLoc, privPushPinName)
        End With
            
        objPushPin.BalloonState = geoDisplayName
        
        objPushPin.MoveTo pubMap.DataSets.Item(privPushPinName)
        
        lngX = pubMap.LocationToX(objLoc)
        lngY = pubMap.LocationToY(objLoc)
        
        If &#40;lngX < 0 Or lngX > pubMap.Width&#41; Or &#40;lngY < 0 Or lngY > pubMap.Height&#41; Then
            objPushPin.Location.GoTo
        End If
                
        Set objPushPin = Nothing
        Set objDataSet = Nothing
        Set objRecordset = Nothing
        
    End Sub

  9. #9
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    Sylvain,

    I have only looked at the code for a few moments but I have to ask you why is it nessasary to run the code within the Timer1 Control EVERY 5000 milliseconds (12 times per second)?

    I think maybe you are overloading the system?

    What version of windows are you running? If you have NT/Win2000/XP I would be intrested to see CPU usage as time goes on after you start this Timer Control.

    Please let me know what you think.

  10. #10
    Sylvain is offline Junior Member Yellow Belt
    Join Date
    Aug 2002
    Posts
    12
    John, it works on 98/ME/NT/XP with other application running at the same time. I never used a timer before but I did not find it to be that bad on CPU. So far, it never created a problem or conflict with other apps.

    The test I send you was every 5 seconds just for testing; the live system retrieve the information from 1 to 6 times a minute, depending how often the user has to see the information.

    The timer is just one way of avoiding doing a push from the server to the client. The real code retrieves the records from a SQL server every elapse time.

    Sylvain

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. PushPin dataset is saved in .ptm?
    By PeppeM in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 05-06-2006, 12:53 PM
  2. Add a newly created Pushpin to Dataset
    By Yazzy in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 08-24-2005, 01:46 PM
  3. Having problems getting location from pushpin
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 11-02-2004, 10:33 AM
  4. delphi iterate pushpin dataset
    By merlino in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 10-12-2004, 09:20 AM
  5. Find Nearby Pushpin in dataset
    By Dazzer in forum Products: Pushpin Tool, Single State Mapper
    Replies: 1
    Last Post: 10-16-2003, 03:05 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