View Full Version : Adding Multiple Pushpin Sets to Map

11-12-2010, 12:42 PM
I'm new at working with excel vba code for mappoint so thans in advance and sorry for not. The code below takes data from an excel speadsheet and send that data to mappoint. Can't figure out how to send multiple datasets to the same ActiveMap as this code creates a new mappoint file everytime it runs.

Private Sub submitMapChoice_Click()
Set mapdataSheet = Sheets("MapData")

If Me.MapPointOption.Value Then

'Run macro that creates dataset to export to Mappoint
ActiveWorkbook.Unprotect Password:="DanJoannWinkler"
mapdataSheet.Visible = True

'Run macro to transform 20 detailed concept to 8 generic concepts
If Me.MapPointOption.Value = True Then Me.ChangeConcept
Unload Me

Set oApp = CreateObject("MapPoint.Application.NA")
Set objMap = oApp.NewMap

'start reading on row 2 of spreadsheet
nReadRow = 2

'test to see if there is an address in column 1 (A) for the current row
Do While Sheets("MapData").Cells(nReadRow, 1) <> ""

MyLat = Sheets("MapData").Cells(nReadRow, 1)
MyLon = Sheets("MapData").Cells(nReadRow, 2)
szname = Sheets("MapData").Cells(nReadRow, 4)
Set objLoc = objMap.GetLocation(MyLat, MyLon, 0)
Set objPushpin = objMap.AddPushpin(objLoc, szname)
objPushpin.Note = "Dev - " & Sheets("MapData").Cells(nReadRow, 5)

'Determine color of pushpin based upon concept
Dim stylenum As Integer
stylenum = 0
currentstyle = Worksheets("MapData").Cells(nReadRow, 3)
Select Case (currentstyle)
Case "Apartments":
stylenum = 17 ' red
Case "Medium Density Attached":
stylenum = 22 ' green
Case "High Density Attached":
stylenum = 23 ' purple
Case "Condo Conversion":
stylenum = 21 ' blue-green
Case "Detached":
stylenum = 20 ' blue
Case Else:
stylenum = 18 ' yellow
End Select
objPushpin.Symbol = stylenum
If Me.ShowLabels = True Then
objPushpin.BalloonState = geoDisplayName
End If
nReadRow = nReadRow + 1

oApp.Visible = True
oApp.WindowState = geoWindowStateMaximize
objMap.DataSets(1).Name = "MarketPointe - ResidentialTrends"
End If
End Sub

11-15-2010, 08:59 AM
Add a new pushpin set (pushpin dataset) using the Datasets's AddPushpinSet method.


myMap.DataSets.AddPushpinSet("My New Pushpin Set")

After creating a pushpin, you can move it to a different pushpin set by using the MoveTo() method:

myPushpin.MoveTo("My New Pushpin Set")

Both are described in MapPoint's help file.


11-15-2010, 04:58 PM
How to I activiate an opened map so I can send a second dataset to that map as the following code always opens a new map window

Set oApp = CreateObject("MapPoint.Application.NA")
Set objMap = oApp.NewMap

11-16-2010, 08:01 AM
Yes that code creates a new map. I don't understand what you mean: MapPoint can only display one map at a time.


11-16-2010, 10:42 AM
I have a map open with a pushpin set already on that map. Now I want to add an additional set of pushpins to the map. I've found code such as the following but when I try to run it nothing happens.

Sub NewPushpinSet() Dim oMap As MapPoint.Map Set oMap = GetObject(, "MapPoint.Application").ActiveMap Dim oPPSet As MapPoint.DataSet Dim oPin As MapPoint.Pushpin Dim oDS As MapPoint.DataSets Set oPin = oMap.AddPushpin(oMap.FindResults( _ "Space Needle, Seattle, WA")(1)) Set oDS = oMap.DataSets Set oPPSet = oMap.DataSets.AddPushpinSet("Deliveries") oPin.MoveTo oPPSetEnd Sub