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 13

Pushpins from shapes

This is a discussion on Pushpins from shapes within the MapPoint Desktop Discussion forums, part of the Map Forums category; I have seen posts discussing how to find pushpins in shapes. The solution suggested was to use the 'Dataset.QueryShape' method. ...

  1. #1
    glennuser is offline Junior Member White Belt
    Join Date
    Mar 2004
    Posts
    4

    Pushpins from shapes

    I have seen posts discussing how to find pushpins in shapes. The solution suggested was to use the 'Dataset.QueryShape' method.

    As a new MapPoint user, I can't figure out *how* to set things up (in code) in order to use this method.

    Assuming I have a map with shapes, and each shape has a pushpin in (on?) it, what steps, in code, would I need to go through? I would like to generate a collection (dataset? resultset?) that holds all pushpins found in each shape. (My sense is that we're talking on the order of 10 lines of code.)

    Thanks very much.

  2. #2
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    Have you taken a look in mappoint.chm ? It should be loacated in your mappoint directory. (compiled help file)

    Open it
    click programming information (Last item in list)
    click Microsoft MapPoint Visual Basic Reference
    click Methods
    click QueryShape method

  3. #3
    glennuser is offline Junior Member White Belt
    Join Date
    Mar 2004
    Posts
    4
    Yes, I was there.

    But this code segment (which is from that example):

    'Let user create a data map
    Set objDataSet = _
    objApp.ActiveMap.DataSets.ShowImportWizard


    opens up a dialog box, and prompts me to import a data file that I don't have.

    Why must I import a data file in order to retrieve a Recordset of pushpins and shapes?

  4. #4
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    Just comment that out and run it again. Thats there for example in case you do not have and data on the map (pushpins)

  5. #5
    glennuser is offline Junior Member White Belt
    Join Date
    Mar 2004
    Posts
    4
    But doesn't that still leave me without a valid objDataSet?

    This line will fail:
    Set objRecords = objDataSet.QueryShape(objShape)

    As you suggest, there should be a dataset available from my pushpins.

    I found this in the help file:
    " ... or when you create a Pushpin with the Create Pushpin drawing tool. The default name of this data set is My Pushpins. "

    So, I tried this:
    Set objDataSet = objmap.DataSets("My Pushpins")

    But I get the following error:
    "The requested member of the collection does not exist. Use a valid name or index number."

  6. #6
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    Ok, Here is an example that will create a drivetimezone (a shape) and report how many pushpins are in it. (Put a pushpin in Tampa, FL) You should be able to adapt this to work with other shapes as needed.... My MapPoint Control is named MapPointCtl so you may need to edit the code or change the name of your control.... Let me know if you have success with this sample.

    Code:
    Dim objmap As MapPointCtl.Map
    Dim objDataSet As MapPointCtl.DataSet
    Dim objRecords As MapPointCtl.Recordset
    Dim objshape As MapPointCtl.Shape
    Dim lngCount As Long
    Dim objloc1 As MapPointCtl.Location
    Dim aDriveTimeZone As MapPointCtl.Shape
    
    Set objmap = MappointControl1.ActiveMap
    Set objloc1 = objmap.FindResults("Tampa, FL").Item(1)
    Set objshape = objmap.Shapes.AddDrivetimeZone(objloc1, 20 * geoOneMinute)
    objshape.Select
    
    For Each objDataSet In objmap.DataSets
     Set objRecords = objDataSet.QueryShape(objshape)
     objRecords.MoveFirst
      Do While Not objRecords.EOF
       lngCount = lngCount + 1
        objRecords.MoveNext
      Loop
    Next
    MsgBox "Number of records in shape: " & lngCount

  7. #7
    glennuser is offline Junior Member White Belt
    Join Date
    Mar 2004
    Posts
    4
    Fantastic.

    Thanks very much for your continued assistance.

    I think I'm on my way -- thanks to you.

    Best wishes,

    -- Glenn

  8. #8
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    Thanks for the kind words,

    Take care,

  9. #9
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Quote Originally Posted by John Meyer
    Ok, Here is an example that will create a drivetimezone (a shape) and report how many pushpins are in it. (Put a pushpin in Tampa, FL) You should be able to adapt this to work with other shapes as needed.... My MapPoint Control is named MapPointCtl so you may need to edit the code or change the name of your control.... Let me know if you have success with this sample.

    Code:
    Dim objmap As MapPointCtl.Map
    Dim objDataSet As MapPointCtl.DataSet
    Dim objRecords As MapPointCtl.Recordset
    Dim objshape As MapPointCtl.Shape
    Dim lngCount As Long
    Dim objloc1 As MapPointCtl.Location
    Dim aDriveTimeZone As MapPointCtl.Shape
    
    Set objmap = MappointControl1.ActiveMap
    Set objloc1 = objmap.FindResults("Tampa, FL").Item(1)
    Set objshape = objmap.Shapes.AddDrivetimeZone(objloc1, 20 * geoOneMinute)
    objshape.Select
    
    For Each objDataSet In objmap.DataSets
     Set objRecords = objDataSet.QueryShape(objshape)
     objRecords.MoveFirst
      Do While Not objRecords.EOF
       lngCount = lngCount + 1
        objRecords.MoveNext
      Loop
    Next
    MsgBox "Number of records in shape: " & lngCount
    hi,

    i tried the exact thing above and it doesnt return any records. i've been trying this for quite a while now, but numerous attempts have only led to frustration. it doesnt give an errormessage or something, but the above example doesnt create any datasets.
    is a dataset supposed to be created automatically when a queryshape is executed? is there some setting for this?

    would be thankfull for any replies..

  10. #10
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    Did you add some pushpins to the tampa area?

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. Naming Shapes
    By Daniel in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 08-19-2004, 05:49 AM
  2. Transparent shapes
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 06-01-2003, 01:59 PM
  3. ZOrder of Pushpins and Shapes
    By rbarthels in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 04-14-2003, 02:09 AM
  4. Drawing shapes on the ocx
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 10-01-2002, 05:54 AM
  5. Posting pushpins and shapes in a map
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 08-28-2002, 11:19 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