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

Help, problem showing a location twice

This is a discussion on Help, problem showing a location twice within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi, I'm developing an application with visual basic and mappoint 2002 Europe, and I have a problem with a try. ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002

    Help, problem showing a location twice


    I'm developing an application with visual basic and mappoint 2002 Europe, and I have a problem with a try.

    I have a form with a Mappoint Control on it, a listview, a textbox (in order to indicate the place to find), and two command buttons.

    When clicking the first command button, I search for the place on the textbox and put the results in the listview. Then, I select one of the results on the listview and click the second command button in order to go to that location.

    The problem arises when I try to go to a location previously shown. Then, I'm shown the error 13 in runtime.

    Do you know what the problem is?

    Here is the code:

    Option Explicit

    Dim oMap As MapPoint.Map

    Private Sub buscar_Click()
    End Sub

    Private Sub Command1_Click()
    Dim oLoc As MapPoint.Location

    MsgBox ListView1.SelectedItem.Text
    Dim oPin As MapPoint.Pushpin

    Set oLoc = oMap.FindResults(ListView1.SelectedItem.Text)(1) 'Here is when the error message is shown.

    Set oPin = oMap.AddPushpin(oLoc)
    oPin.BalloonState = geoDisplayBalloon
    oPin.BalloonState = geoDisplayName
    oPin.BalloonState = geoDisplayNone
    oPin.Symbol = 133
    oPin.Highlight = True
    Set oLoc = Nothing

    'If I comment the lines with oPin, it works, but I need the Pushpin.
    'If I comment Set oLoc=Nothing, it fails again.
    End Sub

    Private Sub Form_Load()
    MappointControl1.NewMap geoMapEurope
    ListView1.View = lvwReport
    ListView1.FullRowSelect = True
    ListView1.GridLines = True
    ListView1.HideSelection = False
    ListView1.ColumnHeaders.Add , , "Place", ListView1.Width
    End Sub

    Private Sub Form_Unload(Cancel As Integer)
    MappointControl1.ActiveMap.Saved = True
    End Sub

    Sub Mostrar()
    Dim oFound As MapPoint.FindResults

    Set oMap = GetObject(, "MapPoint.Application").ActiveMap

    Set oFound = oMap.FindPlaceResults(Text1.Text)
    If (oFound.Count > 0) Then
    Dim i As Integer
    i = 1
    For i = 1 To oFound.Count
    ListView1.ListItems.Add , , oFound.Item(i).Name
    End If
    End Sub

    Thanks a lot...

  2. #2
    Martel is offline Junior Member Yellow Belt
    Join Date
    Feb 2003
    I am using MapPoint 2002 NA, not Europe, but I think this is probably handled the same way in both versions. What is happening is you are assigning the "Name" that is found in your first search as the name of your pushpin. When I tried you code as you presented it I was able to get the same error on any place where the display name was the same as the FindResults or FindPlaceResults name. Try making the following modifications:

    1. First thing I would do is move this line from your Mostrar subroutine in to a Form_Load subroutine:
    'Set oMap = GetObject(, "MapPoint.Application").ActiveMap
    furthermore, I would change it to
    Set oMap = MappointControl1.ActiveMap
    This will perform your actions on your form instead of the first instance of MapPoint that GetObject manages to grab. As it is, GetObject has the bad habit of grabbing a different instance of MapPoint than the control on the form (assuming I have MapPoint open). If you want to reset the map each time you can just use the following in place of your GetObject:
    Set oMap = MapPointControl1.NewMap&#40;<insert your template name here>&#41;
    2. In your Command1 subroutine, change
     Set oPin = oMap.AddPushpin&#40;oLoc&#41;
    Set oPin = oMap.AddPushpin&#40;oLoc, "* " & oLoc.Name&#41;
    and see if this fixes your error. If you continue having problems, you may have to change the "*" to a different character each time.

    You can also take a shortcut in Command1_Click:
    Set oPin = oMap.AddPushpin&#40;oMap.FindResults&#40;ListView1.SelectedItem.Text&#41;&#40;1&#41;, "*" & ListView1.SelectedItem.Text&#41;
    and bypass the location object altogether, unless you need it to do something else.

  3. #3
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Thanks a lot for your answer, I'll try it!!!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. I need to a map showing only my state with the nam....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 07-20-2012, 03:40 PM
    By MAKAZA in forum MapPoint Desktop Discussion
    Replies: 7
    Last Post: 11-22-2005, 02:47 PM
  3. showing area's on one map.
    By Jade in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 04-08-2003, 06:46 AM
  4. Is this a problem of location or programmation ?
    By Vincent BENNER in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 12-17-2002, 06:57 AM
  5. Showing Zipcodes
    By shaistasohail in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 09-03-2002, 06:03 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