Community of MapPoint and Virtual Earth Users and Developers
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 ...
| |||||||
| Today's Posts | Twitter Feed | Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| MapPoint Programming.... Creating a Route 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 Code: mpRecordset.MoveFirst
Do Until mpRecordset.EOF
mpRoute.WayPoints.Add(mpRecordset("POSTALCODE").Value)
mpRecordset.MoveNext
Loop
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 |
| |||
|
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 |
| |||
| Re: MapPoint Programming.... Creating a Route Quote:
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 |
| |||
| 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 |
| ||||
|
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 |
| |||
| Quote:
Phil |
| |||
|
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. |
![]() |
| Tags |
| creating, mappoint, programming, route |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| 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 |
Taba Heights Holiday
Visit Egypt with your Taba Heights holiday. Book through UlookUbook and save!