PDA

View Full Version : How to change the symbol of the pushpin sets



john453
08-09-2011, 03:33 PM
Hello, everyone:

I am a beginner to Mappoint and Thank everyone so much for what you haved done for me. In terms of how to add pushpin to the map. Thank you so much for helping me out ,Eric. Now, I have a new problem:

I have two columns of post code in the EXCEL and I have to add pushpins for each of them. In addition, the symbol of the pushpins with the same column should be the same. and different column will use different symbols. So, in this case, there should be two different symbols to represent the two columns. Now The code is written and it turned out to be working. The problem is that the two symbols can be only applied two post code rather than the whole sets of post code. The code is in the follows and the example is the attached file:

"
Private Sub Add_Pushpins_Click()

Dim objApp As MapPoint.Application
Dim objFR As MapPoint.FindResults
Dim objLoc As MapPoint.Location
Dim str As String
Dim oPin As MapPoint.Pushpin

Set objApp = CreateObject("MapPoint.Application.EU.16")
objApp.Visible = True
objApp.UserControl = True
alt = objApp.ActiveMap.Altitude

For j = 1 To 20

str = Cells(j, 1)


Set objFR = objApp.ActiveMap.FindAddressResults(, , , , str, geoCountryUnitedKingdom)

Set objLoc = objFR(1)
objApp.ActiveMap.AddPushpin objLoc, "Rural Area"

objApp.ActiveMap.FindPushpin("Rural Area").BalloonState = geoDisplayBalloon
objApp.ActiveMap.FindPushpin("Rural Area").Symbol = objApp.ActiveMap.Symbols(20)

Next


For j = 1 To 20

str = Cells(j, 2)


Set objFR = objApp.ActiveMap.FindAddressResults(, , , , str, geoCountryUnitedKingdom)

Set objLoc = objFR(1)
objApp.ActiveMap.AddPushpin objLoc, "Urban Area"

objApp.ActiveMap.FindPushpin("Urban Area").BalloonState = geoDisplayBalloon
objApp.ActiveMap.FindPushpin("Urban Area").Symbol = objApp.ActiveMap.Symbols(10)


Next


objApp.ActiveMap.DataSets.ZoomTo
objApp.ActiveMap.Altitude = alt

End Sub
"

Can anybody help me to figure out as to how to modify the code so that the symbol can be used on all the added pushpins rather only one?

Mattys Consulting
08-09-2011, 04:18 PM
Setting the symbol for a dataset requires only that you have:

Dim ds As MapPoint.DataSet
~
Set ds = objApp.ActiveMap.DataSets(x)
ds.Symbol = x

'Clean up.
Set ds = Nothing

john453
08-09-2011, 06:03 PM
Thanks very much for your help! I copied your code into the program, it is not working. Sorry for that, as I am not quite familiar with this software , can you be more specific and write the code for me please?

I cannot thank you enough!

Mattys Consulting
08-10-2011, 07:21 PM
You reall only need to make the symbol the same in both loops where it reads:
objApp.ActiveMap.Symbols(20)
Just change the 10 to a 20 and you'll have it.

john453
08-11-2011, 08:43 AM
Thank you for idea, mate, I got it . Finally, it is working ! Thanks!