Community of VE/MapPoint Users and Developers
This is a discussion on Problems with Pushpin dataset within the MapPoint 2006/2009 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 ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Problems with Pushpin dataset 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 |
| ||||
|
I think you will have to post the code behind your find button before we can help you debug it.
__________________ John http://www.support-pc.com Order MapPoint 2006 Here https://secure.mp2kmag.com/?refer=support-PC |
| |||
|
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 |
| ||||
|
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")
__________________ John http://www.support-pc.com Order MapPoint 2006 Here https://secure.mp2kmag.com/?refer=support-PC |
| |||
|
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 |
| ||||
|
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
__________________ John http://www.support-pc.com Order MapPoint 2006 Here https://secure.mp2kmag.com/?refer=support-PC |
| |||
|
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 (lngX < 0 Or lngX > pubMap.Width) Or (lngY < 0 Or lngY > pubMap.Height) Then
objPushPin.Location.GoTo
End If
Set objPushPin = Nothing
Set objDataSet = Nothing
Set objRecordset = Nothing
End Sub
|
| ||||
|
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.
__________________ John http://www.support-pc.com Order MapPoint 2006 Here https://secure.mp2kmag.com/?refer=support-PC |
| |||
|
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 |
![]() |
| Tags |
| dataset, problems, pushpin |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PushPin dataset is saved in .ptm? | PeppeM | MapPoint 2006/2009 Discussion | 1 | 05-06-2006 01:53 PM |
| Add a newly created Pushpin to Dataset | Yazzy | MapPoint 2006/2009 Discussion | 1 | 08-24-2005 02:46 PM |
| Having problems getting location from pushpin | Anonymous | MapPoint 2006/2009 Discussion | 0 | 11-02-2004 11:33 AM |
| delphi iterate pushpin dataset | merlino | MapPoint 2006/2009 Discussion | 1 | 10-12-2004 10:20 AM |
| Find Nearby Pushpin in dataset | Dazzer | Products: Pushpin Tool, Single State Mapper | 1 | 10-16-2003 04:05 PM |