MapPoint Forums

MapForums

Community of MapPoint and Virtual Earth Users and Developers




Placing PushPins using VBA programing

This is a discussion on Placing PushPins using VBA programing within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; I am now to MapPoint automation and am in the midst of have to modify and existing MSAccess 2K application ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Today's Posts Twitter Feed Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

View Poll Results: Is the Curse of the Bambino finally broken?

Yes 2 66.67%
No 1 33.33%
Voters: 3. You may not vote on this poll

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-28-2004
Junior Member
White Belt
 
Join Date: Oct 2004
Posts: 7
Placing PushPins using VBA programing

I am now to MapPoint automation and am in the midst of have to modify and existing MSAccess 2K application that interfaces with the MapPoint 11 activeX object. My task is to read a table containing records where each record has a longitude and latitude field. My task is to do the following:

Read each record, place a pushpin that looks like a green factory at the location indicated by its Long and Lat values.

Has anyone been able to accomplish such a task and if so, is there any example visual basic code? Any help would be greatly appreciated.

Thanks
jburgess
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 10-28-2004
Winwaed's Avatar
Mapping-Tools.com
Black Belt
 
Join Date: Feb 2004
Posts: 1,142
Blog Entries: 22
I assume you have a copy of MapPoint? Looking the help. Under programming information, there are a number of pages about how to do specific things - eg. locations, routes, polygons.
Look at the locations and pushpins example.
You need to create a Location object from your lat/long coordinate.
Then you create a pushpin object using the Location object.
You can set the symbol type or load one of your own.



Richard
__________________
Winwaed Software Technology LLC
http://www.winwaed.com
See http://www.mapping-tools.com for MapPoint Tools
See the Geoweb Guru for online mapping
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 10-29-2004
Junior Member
White Belt
 
Join Date: Oct 2004
Posts: 8
re: Placing PushPins using VBA programing

As an aside, I find that the app is quicker if I simply save the long/lats to a CSV and load it as a dataset; otherwise, I get "the curse of the flickering hourglass" as it adds each pin in turn.

Just a thought; do it any way that makes you happy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 10-29-2004
Junior Member
White Belt
 
Join Date: Oct 2004
Posts: 7
Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 02-14-2008
Junior Member
White Belt
 
Join Date: Feb 2008
Posts: 9
Placing PushPins using VBA programing

I have also a problem with setting pushpins with a vba code. At first I calculte a distance matrix and afterwards I want to add a pushpin to each of my addresses, but it doesn´t work...
Here is my code:

Sub Distance()
Dim oApp As New MapPoint.Application
oApp.Visible = True
oApp.UserControl = True
oApp.ActiveMap.Saved = True
oApp.Units = geoKm
Dim objFindResults As MapPoint.FindResults
Dim objLoc As MapPoint.Location
Dim objPushpin As MapPoint.Pushpin
Dim i As Integer
Dim j As Integer
Dim PLZ1, PLZ2 As String
Dim STADT1, STADT2 As String
Dim ADDRESSE1, ADDRESSE2 As String
Dim dist As Double

Set oApp = CreateObject("MapPoint.Application")
Set objMap = oApp.ActiveMap
Set objRoute = objMap.ActiveRoute
For i = 2 To 4
PLZ1 = Tabelle1.Cells(i, 2)
STADT1 = Tabelle1.Cells(i, 3)
ADDRESSE1 = Tabelle1.Cells(i, 4)

For j = i + 1 To 4
PLZ2 = Tabelle1.Cells(j, 2)
STADT2 = Tabelle1.Cells(j, 3)
ADDRESSE2 = Tabelle1.Cells(j, 4)

objRoute.Waypoints.Add objMap.FindAddressResults(PLZ1, STADT1, ADDRESSE1).Item(1)
objRoute.Waypoints.Add objMap.FindAddressResults(PLZ2, STADT2, ADDRESSE2).Item(1)
objRoute.Calculate
'Set objLoc = objMap.FindAddressResults(Plz1, stadt1, addresse1)
'objMap.AddPushpin (objLoc)
dist = objRoute.Distance
Debug.Print i & "," & j
Debug.Print "distance " & dist
objRoute.Clear
Next j
Next i
oApp.Quit
End Sub

When I run the makro without the red pushpin part everything works great. But with that part it doesn´t work. I don´t know how to add pushpins in this case but I know that the red part works in other makros...
Can anybody help me?

Already thanks
Kikolino
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 02-15-2008
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,177
Re: Placing PushPins using VBA programing

Hi,

You probably will have an exception if you step with the debugger trough it. FindAddressResults returns a collection of Location object, not a Location object. So something like this should work:
Code:
Dim objLocResults As MapPoint.FindResults;
objLocResults = objMap.FindAddressResults(Plz1, stadt1, addresse1);
objMap.AddPushpin(objLocResults_Item(1));
Please check my syntax, as I'm not a VBA programmer
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 02-15-2008
Junior Member
White Belt
 
Join Date: Feb 2008
Posts: 9
Re: Placing PushPins using VBA programing

Hi Wilfried!

Thanks for your quick answer but unfortunately it doesn´t work... Even with the right syntax

Set objLocResults = objMap.FindAddressResults(PLZ1, STADT1, ADDRESSE1)
objMap.AddPushpin (objLocResults.Item(1))

Runtime error 438 appears.

Greetz Kikolino
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 02-19-2008
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,177
Re: Placing PushPins using VBA programing

Hi,

You should first check the ResultsQuality property. Maybe there is no Location returned from that particular address. Sorry I was incomplete..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 03-04-2008
Junior Member
White Belt
 
Join Date: Feb 2008
Posts: 9
Re: Placing PushPins using VBA programing

Hi Wilfried!
Thanks, but it still doesn´t work, always the same error... But there is a result found for the address.

Greetz Kikolino
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 03-05-2008
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,177
Re: Placing PushPins using VBA programing

Hi,

then something else should be wrong. did you try a simple test like this? eventually with other addresses and so ? this is C# but you can easy translate it into VBA. Piece of code is tested:

Code:
    int name = 1;
    FindResults addrResults = MP.ActiveMap.FindAddressResults("churchilllaan", "Schoten", "", "", "", GeoCountry.geoCountryBelgium);
    foreach (object o in addrResults) {
        Location loc = o as Location;
        if (loc == null)
            continue;
        MP.ActiveMap.AddPushpin(loc, name.ToString());
        name++;
    }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
placing, programing, pushpins, vba


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Creating a subset of Pushpins from a set of pushpins paf33 MapPoint 2006/2009 Discussion 3 08-09-2005 04:54 AM
Pl.. Help ----Locating/ placing positions in India Anonymous MapPoint 2006/2009 Discussion 0 11-13-2003 02:20 AM
Programmatically Placing Pushpin on a Line jbendiner MapPoint 2006/2009 Discussion 0 01-05-2003 10:18 PM


All times are GMT -5. The time now is 07:19 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 RC2
MP2K Magazine
Visitor Map

Thassos Holidays
Visit an unspoilt and beautiful Greek island with Thassos holidays available through UlookUbook.



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