Community of VE/MapPoint Users and Developers
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 ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Need help increasing speed adding a set of pushpins 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 ();
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();
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 |
| |||
| 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 |
| |||
| 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.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| 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 Thank you again for your answers. Cheers, Sino |
| |||
| 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? |
| |||
| 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 |
| |||
| 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 |
| |||
| 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) |
![]() |
| Tags |
| adding, increasing, pushpins, set, speed |
| ||||
| 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 | |
| |
| ||||
| 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 |
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!