Mass update of Polylines
- Does anybody know of a way to set an option for all Polylines in a map in one go?
I hav many lines with many points on my map, and need to change whetehr they are clickable or not. I am currenlty doing this by looping through them all, but this is getting very slow as I add more polylines:
for ( routeid in polylines){
polylines[routeid].reset( LatLonPoints[routeid], { clickable : false } );
}
(polylines is an array containing all the polylines, and LatLonPoints is an array containing the points array for each polyline)
Answers
- PS - been trying to use fromPixelToLatLon to get round this, but with no success. Again the docs are a bit limited, do you ahve an example of this in action?
Edit - hang on, just realised you covered that in this thread http://social.msdn.microsoft.com/Forums/en-US/multimapapi/thread/e820fe3c-0ba8-4678-b286-9bd50cc0dd0e/... all workign noe, thanks for the advice Ross!- Marked As Answer byJohn-SheridanMSFT, ModeratorWednesday, November 11, 2009 12:32 PM
All Replies
- Why not change the approach; leave the polylines alone (as clickable) and change the behaviour of the click listener to "do nothing".
Whether you have one or many listeners, they can examine a global "switch" variable to see if action is allowed or not. - Could work... will let you know...
Actually, I had already thought of something similar and ran into difficulties. To explain....
I already have one click handler for the "original" state, which will show a pop-up (ie make the 'routeBox' div visible) if you click on a line:
function clickHandlerMain(eventType, target, arg3, arg4, arg5)
{
if(eventType=='click'){
if( target instanceof MMPolyLineOverlay ) {
document.getElementById('routeBox').style.visibility = 'visible';
}
}
}
and another for the new state, which lets you draw polylines:
function clickHandlerDraw(eventType, target, arg3, arg4, arg5)
{
if(eventType=='click'){
curPoints.push(arg3);
addPolyline ();
}
}
So when you click "draw", it executes the following (this is currently when it also loops through making all polylines un-clickable):
mapviewer.removeEventHandler( 'click', clickHandlerMain );
mapviewer.addEventHandler( 'click', clickHandlerDraw );
Now, I hoped that if I didn't bother make the polylines un-clickable, the above would act pretty much as you said - clicks on the lines would no longer show the 'routeBox' div and instead, all clicks would draw the polyline.
The first works OK, but because the lines are still clickable, it doesn't appear to pass the arg3 variable correctly - from what I can tell it gives this in screen coordinates instead of lat/lon, though the documentation (http://clients.multimap.com/share/documentation/api/1.2/classes/) isn't clear on this...
...any ideas?!- PS - been trying to use fromPixelToLatLon to get round this, but with no success. Again the docs are a bit limited, do you ahve an example of this in action?
Edit - hang on, just realised you covered that in this thread http://social.msdn.microsoft.com/Forums/en-US/multimapapi/thread/e820fe3c-0ba8-4678-b286-9bd50cc0dd0e/... all workign noe, thanks for the advice Ross!- Marked As Answer byJohn-SheridanMSFT, ModeratorWednesday, November 11, 2009 12:32 PM

