View Full Version : Add Waypoints Starts to get Really Slow

Eric Frost
03-28-2012, 12:58 PM
After 30 or so stops, it seems adding waypoints starts to get really slow...

Waypoints collection (http://msdn.microsoft.com/en-us/library/gg662960.aspx)

My code is very simple, it's just looping over a recordset and adding the recordset location.

For the Waypoint Anchor, I tried adding the recordset location, the recordset's pushpin object, and the pushpin's location, no matter which it didn't seem to make a difference.

When it gets up to around 60+ waypoints, it can take 2 seconds to add each waypoint.

I have about 40 routes with around 80 stops each, so you can see this could easily take hours.

Is there a way to maybe add all the waypoints in a batch? With the regular interface, you can right-click on a Pushpin set in the Legend and select Add As Stops in one fell swoop and this is very fast. I don't see any equivalent in the Windows API. Maybe I have to get out WinSpy and figure out what windows message to send? (I'm not confident I could figure this out myself.)

Anyway, any advice or pointers much appreciated!


Mattys Consulting
04-02-2012, 02:57 PM
Hi Eric,

I usually start a new map after a determined amount of pushpins or routes.
Clearing all instantiated class variables is important to that process.
Keeping the map invisible until calculation is finished helps a great deal also.

I'll look into the batch adding part - that is interesting.

Eric Frost
04-03-2012, 06:33 AM
I'll look into the batch adding part - that is interesting.

If you figured this out, that would be really awesome!


Jonathon Smith
04-17-2012, 08:07 AM
I expect the problem is to do with how poor MapPoint's garbage collection is. Everything I do with MapPoint via automation is wrapped into a class that saves the map and reopens after x number of actions which forces MapPoint to release memory that it otherwise would just hold onto, the problem seems especially bad when importing from data sets because it seems MapPoint pulls all the data it is importing into memory and just keeps it there until you close the map.

Eric Frost
04-17-2012, 09:37 AM
For my specific project, I still loop over the recordset and add waypoints individually, but I was able to speed it up a lot by just working with a single route at a time.

What I done initially, was import ALL the routes (could be 30 or 50) and then drill down and work with individual routes, but still having all the routes as separate datasets in the legend.

I think because my map had so much stuff on it (literally thousands of pushpins and dozens of datasets) it was getting seriously bogged down.

By simply importing one route at a time, and then start with a new map for the next route, the processing time for this project was bearable.

Nonetheless, it would still be a LOT faster if I didn't have to loop over the recordset and add waypoints individually, this is by far the biggest bottleneck with this project. In comparison, the Optimization and Calculation of the route does not take much time.