MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Need help increasing speed adding a set of pushpins

This is a discussion on Need help increasing speed adding a set of pushpins within the Development forums, part of the MapPoint 2006/2009 Discussion category; Hi all, I'm not very familiar with MapPoint yet, but already got some basics. However, currently I have a problem ...


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

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



Click here to register

Reply

 

LinkBack (1) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 02-04-2008
Junior Member
White Belt
 
Join Date: Oct 2007
Posts: 3
Need help increasing speed adding a set of pushpins

Hi all,
I'm not very familiar with MapPoint yet, but already got some basics. However, currently I have a problem when displaying a bunch of push-pins. Somewhere here in the fourm I found code importing data from a file, which works fine.
That's the code:
Code:
            m_dsStopPoints = m_DataSets.ImportData(m_strStopPointsPath, NULL, geoCountryDefault, geoDelimiterDefault, NULL);
            m_dsStopPoints.SetSymbol(18);
            int iLength = m_dsStopPoints.GetRecordCount();

            if(!m_dsStopPoints.GetRecordCount ())
                return;

            m_DataSets.ZoomTo ();
That code needs around 0.5 seconds for importing and displaying around 135 pushpins. Unfortunatelly the pushpins I need to display are not contained in a file, but in memory instead. So the code above does not work. The code I use for my purpose is as follows:
Code:
        _myPushPinSet= m_DataSets.AddPushpinSet(L"Pushpins");

        for(itGPSPoints = _vecStopPoints.begin() ; itGPSPoints != _vecStopPoints.end(); itGPSPoints++)
        {
            locLocation = m_objMap.GetLocation( (*itGPSPoints)->GetLatitude(), (*itGPSPoints)->GetLongitude(), 2.0);
            pinPushpin = m_objMap.AddPushpin(locLocation, L"Stoppoint");
            pinPushpin.SetSymbol(18);
            pinPushpin.MoveTo(_setStopPoints);
        }
        _myPushPinSet.SetFieldNamesVisibleInBalloon(TRUE);
        _myPushPinSet.ZoomTo();
So I create a "CDataSet" and fill it with points ("itGPSPoints" is an iterator of a vector containg GPS-Points). However, this code needs arround 3 - 4 seconds, which is 8 times of what the first code does.

My theorie is as follows:
The first code imports all the data first, and then draws them all to the map.
The second code adds the data point by point, and draws them each time a new point is added.
That's just a theory, but would explain why my code is so slow.

Maybe someone can point me out on how to update my code in a way to make it more efficient.

Cheers,

Sino
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-04-2008
Junior Member
White Belt
 
Join Date: Apr 2004
Posts: 10
Send a message via ICQ to 208_Fireball
Re: Need help increasing speed adding a set of pushpins

From what I have seen, every call for the ActiveX control costs time. When you've got calls in a loop, this makes it quite obvious.

You've probably thought of, or discounted the following ideas already:

You could create an add-in for MapPoint which does some of the grunt-work (Add-ins run in-process with MapPoint.)

Alternatively, you could pre-form your mappoint Location objects as soon as you know the lat/lon data for each position you're interested in. This might speed things up a little, if you're using your code more than once per session.

Other than that, I'm out of ideas - sorry!

Cheers,

Dave
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-05-2008
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,105
Re: Need help increasing speed adding a set of pushpins

Hi,

You can do 2 things, and probably you will get for both the same speed. That is writing your data to a file and then import it like in your first code. And secondly call windows API function LockWindowUpdate with the windows handle of the activeX control befor the loop, and again with a null after the loop.

the latter will prevent mappoint by drawing on the screen during the loop. Probably this is the major difference in speed if comparing the individual pushpins and the import.
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-06-2008
Junior Member
White Belt
 
Join Date: Oct 2007
Posts: 3
Re: Need help increasing speed adding a set of pushpins

Thank you for your answers. It sounds obvious that invoking an ActiveX control within a loop slows down ... thank you for pointing that out (a point a I did not think about). The next thing I will try is the thing with the "LockWindowUpdate" function, as this is the easiest way . If that did not work, I will try the other things such as writing my own add-in (a thing I've never tried before) and exporting the data to an external file first (not good programmers style ).
Thank you again for your answers.

Cheers,

Sino
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-26-2008
Junior Member
White Belt
 
Join Date: Sep 2007
Posts: 3
Re: Need help increasing speed adding a set of pushpins

Just tried the lockwindowupdate and it works a treat

I would also like to be able to print a mini map for each of the waypoints, bit like MapPoint does itself. I've got the directions ok, but the map is more tricky. Can you ZoomTo and then take a snapshot?

Any ideas?
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-26-2008
Senior Member
Blue Belt
 
Join Date: Dec 2002
Posts: 242
Re: Need help increasing speed adding a set of pushpins

For the purpose of archive searching, this topic should be moved
to a new thread.

Thanks,

Mike Mattys
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 03-06-2008
Junior Member
White Belt
 
Join Date: Oct 2007
Posts: 3
Re: Need help increasing speed adding a set of pushpins

@diyguypaul
What did you exactly? For me it does not work. When I use "lockWindowUpdate" the added pushPins are only shown after all are added, but the time it needs is still the same. Also it seems as it still invokes a repaint for each added pushpin (at least the OnAfterRedrawMappointCtrl() function is still invoked).
What I have tired is the following:

1. Invoking the "LockWindowUpdate" functin of the mapPoint control directly:
m_wndMapPointCtrl.LockWindowUpdate();
[...]
m_wndMapPointCtrl.UnlockWindowUpdate();

2. Using the LockWindowUpdate(HWND) function
::LockWindowUpdate(m_wndMapPointCtrl.m_hWnd);
[...]
::LockWindowUpdate(NULL);

In both cases the PushPins are only shown after all have been added, but as said above, MapPoint seems to invoke a repaint for each added PushPin.

Cheers,

Sino
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 03-07-2008
Junior Member
White Belt
 
Join Date: Sep 2007
Posts: 3
Re: Need help increasing speed adding a set of pushpins

Hi Sino

Sorry my code is VB.Net but hopefully will help

PrivateDeclareAutoFunction SendMessage Lib"user32.dll" (ByVal hWnd As IntPtr, ByVal wMsg As Int32, ByVal wParam AsBoolean, ByVal lParam As Int32) As Int32
PrivateConst WM_SETREDRAW As Int32 = &HB
PrivateSub PlanIt()
.....
SendMessage(AxMappointControl1.Handle, WM_SETREDRAW, False, 0)

Draw all the pins then when you finished

SendMessage(AxMappointControl1.Handle, WM_SETREDRAW, True, 0)
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
adding, increasing, pushpins, set, speed


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/need-help-increasing-speed-adding-set-pushpins-7081.html

Posted By For Type Date
Working With Excel and MapPoint - MP2K Magazine This thread Refback 02-10-2008 12:28 PM

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
Adding Links / Images to Pushpins... indiehead MapPoint 2006/2009 Discussion 0 11-02-2007 11:45 AM
Adding Excel Data as Pushpins rosshood10 MapPoint 2006/2009 Discussion 3 08-31-2006 11:25 AM
Adding Pushpins from Excel 2003 Marktherob MapPoint 2006/2009 Discussion 2 02-07-2006 05:13 PM
Adding Pushpins Matrices MapPoint 2006/2009 Discussion 1 11-28-2003 10:32 AM
Is there a fast way of adding pushpins? matt1168 MapPoint 2006/2009 Discussion 3 07-24-2003 09:44 AM


All times are GMT -5. The time now is 04:46 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map

Ski Chalets
Don't miss out on the delights of ski chalets. Book accommodation to suit your ski holiday requirement online at Holiday Hypermarket.

Turkey Holidays
Find great Turkey Holidays with Travel Counsellors. A personal Travel Counsellor can help you plan the perfect holiday to Turkey.

Flights to Canada
Looking for cheap flights to Canada? dealchecker.co.uk helps you compare prices from all major scheduled and charter airlines.

All Inclusive Maldives
Visit The Holiday Place.co.uk for great deals on all inclusive holidays to the Maldives. Book a holiday to the outstandingly beautiful Maldives.

Cheap Spain Holidays
Stay well informed when you are searching for cheap holidays online. For useful advice on when to book cheap Spain holidays make sure you look on ulookubook.com

Family activity holidays
Family holidays can be full of fun activity. Check out your options at Travel.co.uk

Gran Canaria Holidays
Visit the Canary Islands! See information on Gran Canaria holidays at On The Beach!


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