MapPoint Forums

MapForums

Community of MapPoint and Virtual Earth Users and Developers




MapPoint Programming.... Creating a Route

This is a discussion on MapPoint Programming.... Creating a Route within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hi, Okay I am doing some research for my company into if MapPoint will do what we need. Heres the ...


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

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-19-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
MapPoint Programming.... Creating a Route

Hi,

Okay I am doing some research for my company into if MapPoint will do what we need.

Heres the deal, what we would need to do, is import into MapPoint a list of addresses (we would mainly be working on Post Codes / Zip Codes etc) and then generate a map with a route on it from these.

My original idea after reading through the technical info for MapPoint was to this:

Code:
Dim mpApplication As MapPoint.Application
Dim mpDataSets As MapPoint.DataSets
Dim mpDataSet As MapPoint.DataSet
Dim mpRecordSet as MapPoint.Recordset
Dim mpMap As MapPoint.Map
Dim mpRoute As MapPoint.Route
Dim mpFieldDefList(4,2) As Variant

mpFieldDefList(1,1) = “ROUTENO”
mpFieldDefList(1,2) = geoFieldData 	‘//Non Geocoding Data

mpFieldDefList(2,1) = “CLIENTNAME”
mpFieldDefList(2,2) = geoFieldData

mpFieldDefList(3,1) = “ADDRESSINFO”
mpFieldDefList(3,2) = geoFieldData

mpFieldDefList(4,1) = “POSTALCODE”
mpFieldDefList(4,2) = geoFieldPostal1  ‘UK Post Code Data Type


Set mpAplication = New MapPoint.Application
mpApplication.Visible = False
mpApplication.UserControl = False

mpApplication.NewMap

Set mpMap = mpApplication.ActiveMap
Set mpRoute = mpMap.ActiveRoute

Set mpDataSets = mpApplication.NewMap.DataSets

Set mpDataSet = mpDataSets.ImportData(gblProgramDatabasePath & “!tblMapRouteData”, mpFieldDefList)

Set mpRecordset = mpDataSet.QueryAllRecords
Now it is at this point I got stuck, I was under the impression I could something like this:

Code:
mpRecordset.MoveFirst
Do Until mpRecordset.EOF
    mpRoute.WayPoints.Add(mpRecordset("POSTALCODE").Value)
    mpRecordset.MoveNext
Loop
I know thats very crude, but its just an example of the idea I had. I thought I would probably need some kind of function to return perhaps a geographic co-ordinate based on the post code I am passing etc...

But I got stuck when I realised that a WayPoint object requires something called an "Anchor" which can either be a Locaton object or pushpin object.

Now I am totally confused after reading Microsofts documentation on how the hell Pushpins work. I read somewhere that an imported data set already has pushpins... but what do these pushpins represent, each record in the dataset? I know pushpins represent marks on the map, I get that, but how do they relate to all this.

How do I get from my post codes in my dataset, to a pushpin object which can be used as an achor for a waypoint object that I want to add to my route.

Basically any help you can offer or information to boost my understanding would be very welcome.

Thanks

- Paul
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 02-19-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Oh and my second question is this,

Granted the above code is Visual Basic, however my company writes all its software in Borland Delphi, so I am wondering if there is going to be any issues there?

I mean in theroy, because it works using COM, and Delphi supports COM and can create a Delphi object wrapper for the MapPoint Object Library so Delphi can work with it, it shouldn't be a problem.. but will it ?

Just to give you some background, the reason we want to use MapPoint is because we have a peice of software that is used in meal deliveries. We want to build in the ability for a customer to see an actual map with their delivery routes on that.

- Paul
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 02-21-2004
Junior Member
White Belt
 
Join Date: Dec 2003
Posts: 8
Re: MapPoint Programming.... Creating a Route

Quote:
Originally Posted by Anonymous
How do I get from my post codes in my dataset, to a pushpin object which can be used as an achor for a waypoint object that I want to add to my route.
Here's the code I use in Delphi to add waypoints to a route:

var
ONE : OleVariant;
FR : FindResults;
Pin : PushPin;

While not MemMappingData.EOF do
begin

FR := mpMap.FindAddressResults( MemMappingData.FieldByName('Address1').AsString, MemMappingData.FieldByName('City').AsString,'',Mem MappingData.FieldByName('State').AsString, MemMappingData.FieldByName('ZIP').AsString,geoCoun tryUnitedStates)

Pin := mpMap.AddPushPin( Location(FR.Item[ONE]), MemMappingData.FieldByName('Name').AsString );

Route.Waypoints.Add( Pin );

MemMappingData.Next;

end;

// Check to make sure there's more than 1 waypoint before Calculating the Route...
if Route.Waypoints.Count > 1 then Route.Calculate;


That should get you started. I don't want to help you too much... my software is for a meal delivery service as well!

Phil Frank
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 02-23-2004
Syd Syd is offline
Member
Yellow Belt
 
Join Date: Aug 2003
Posts: 42
Planning a route

Hi there,

you first search for the address with .Findresult() and then add the first address found to the route?

What if the address is not the first item of the result list? you'll get a wrong route then. It should be the first, but you can't know exactly if the adress is right in the recordset or in mappoint itself.

I do it that way that I'm searching for the postal code to have the right area (ok I'm in Germany and it's perhaps not the way in the United states with the adresses ? ) and then for the whole adress.

greetings,
Syd

btw. if anybody has a better idea, contact me or poste it
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-23-2004
Winwaed's Avatar
Mapping-Tools.com
Black Belt
 
Join Date: Feb 2004
Posts: 1,142
Blog Entries: 22
The FindResults collection has a property called ResultsQuality that is set to geoFindResultGood, geoAmbiguousResults, etc.

This can give you some idea as to how good MapPoint things the returned list of addresses is.


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
  #6 (permalink)  
Old 02-23-2004
Junior Member
White Belt
 
Join Date: Dec 2003
Posts: 8
Quote:
Originally Posted by winwaed
The FindResults collection has a property called ResultsQuality
Yes, in the code example above I was simply illustrating how to add an address to a pushpin and then add the pushpin to a route. I do have code to check the results returned from an address that's been submitted. If there's more than one result returned I ask for user intervention.

Phil
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 10-09-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
This worked for me:

On Error Resume Next
Do Until mpRecordset .EOF
myRoute.Waypoints.Add mpRecordset .Pushpin
mpRecordset.MoveNext
Loop
On Error Goto 0

The error part is because not all pushpins will have valid locations, there is probably a better way to exclude them but I'm new to MapPoint.
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 10-12-2004
Member
Green Belt
 
Join Date: Nov 2002
Posts: 52
Hi,

I have developped a solution for creating a route based on MapPoint. I could send you the program.

Cheers
Rainer
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
creating, mappoint, programming, route


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
Ambiguous messages ( programming or not programming? ) Mohamed MapPoint 2006/2009 Discussion 1 06-13-2006 03:35 PM
Programming MapPoint via .NET Anonymous MP2K Magazine Articles 1 02-21-2006 09:42 AM
Creating a Route Anonymous MapPoint 2006/2009 Discussion 3 08-01-2003 09:44 AM
In using MapPoint in programming with VB how do yo.... Anonymous MapPoint 2006/2009 Discussion 1 11-27-2001 01:53 AM
What is the "Programming Model" of Mappoint, and h.... Anonymous MapPoint 2006/2009 Discussion 1 08-27-2001 11:56 AM


All times are GMT -5. The time now is 07:53 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

Taba Heights Holiday
Visit Egypt with your Taba Heights holiday. Book through UlookUbook and save!



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