1
votes

Im having some trouble refering to bing maps touch controls Ajax7.

I put several polygones on top of the bingmaps interface, in order to display colored geographic regional shapes. Now whenever the user is panning the map or zooming in/out, the huge number of polygones displayed on the map will lead to performance lags.

This code pushes the polygones to the map:

Overlay_Tmp = new Microsoft.Maps.Polygon (region.Shape,region.colortheme );

map.entities.push( Overlay_Tmp );

https://dl.dropbox.com/u/85251516/poly.png

For that reason i decided to set these polygones invisible whenever the user is panning/zooming the map.

The user interaction should be cought by watching the "viewchangestart"/"viewchangeend" event, bound to the bing map, which is fired whenever the mapview is changed by panning/zooming etc.

Microsoft.Maps.Events.addHandler( map, 'viewchangestart', VC_START );
Microsoft.Maps.Events.addHandler( map, 'viewchangeend', VC_END );

This works fine, as long as i am interaction with the blank map interface. viewchangestart is fired when panning/zooming the map, and viewchangeend is fired when stopped panning/zooming.

On the other hand it wont work fine, if the same action is performed within a polygone overlay. The viewchangeend is fired instandly after viewchangestart - so the whole idea doestn work out.

Is there anyone out there who struggled similar problems with polygone overlays or got some better ideas for me ?

Thanks!

1

1 Answers

0
votes

The events are firing as expected. One piece of logic you could add is to calculate the bounding box of the polygon (pass the coordinates into a locationRect). And then check to see if the bounding box overlaps with the bounding box of the map. If it doesn't then hide the map.