asroboy / google-maps-utility-library-v3

Automatically exported from code.google.com/p/google-maps-utility-library-v3
Apache License 2.0
0 stars 0 forks source link

make MarkerManager.prototype.updateMarkers_ just a little bit more efficient #26

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
class-MarkerManager

It would be nice to have the markermanager not refresh the markers on the map 
if its not needed.

For example, if the 'zoomgroup' has not changed and the new zoom/bounds are 
within the previous one then there is no point in refreshing.

I've got a map with around 300 markers (3 diff zoom ranges, so 3*300) and in a 
browser like firefox you can see the refresh every time (markers being readded 
I guess)

Something like

if (this.myBounds.contains(newBounds.getNorthEast()) && 
this.myBounds.contains(newBounds.getSouthWest()) && newzoomgroup == 
this.zoomgroup)
return;

and for zooming out

if ((!this.myBounds.contains(newBounds.getNorthEast()) || 
!this.myBounds.contains(newBounds.getSouthWest())) && newzoomgroup == 
this.zoomgroup && newBounds.z <= this.shownBounds_.z )
return;

(zoomgroup is an array of min,max created by addmarkers)

Additional comments:

For some reason the markermanager v3 is a lot slower than v2. I've used v2 a 
lot (great lib!) and never had such obvious refresh 'issues' before. But since 
google maps v3 is a lot nicer to work with I had to upgrade, and thus ended up 
with markermanager v3.

And as a side note, grouping of the markers is not an option :)

Original issue reported on code.google.com by brobot...@gmail.com on 20 Jul 2010 at 10:29

GoogleCodeExporter commented 8 years ago
Hmm understanable issue.

MarkerManager was ported rather early in v3 development. There might be some 
pieces of code that might be updateable.

I will have a look at your suggestion, maybe i can make it more efficient, 
fresh look sometimes helps

Original comment by bbr...@gmail.com on 28 Dec 2010 at 4:20

GoogleCodeExporter commented 8 years ago
I've had a quick look at the code, the fact is the markermanager removes the 
markers outside the viewport. This requires calculation. So, the set of markers 
might not have changed, the zoom might not have changed, but it does remove the 
markers outside the viewport to make dragging calculations as easy as possible 
for the API.

I might be able to check for other possible bottlenecks but i need a link to 
your page if possible. That way i can check it out with your example, see if 
there is anything in the profiling result that would help.

Original comment by bbr...@gmail.com on 28 Dec 2010 at 4:34