提高谷歌地图的性能 [英] Improving Google Maps Performance

查看:157
本文介绍了提高谷歌地图的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不得出关于10000行的谷歌地图。因此,它花费太多时间在平局()方法。移动地图变得非常laggy。有没有什么办法来缓存绘图或我能画地图/帆布只是这是目前屏幕上看到的部分?

I have to draw about 10000 line on Google Maps. So, it is spending too much time in draw() method. Moving on map becomes very laggy. Is there any way to cache drawing or can I draw just the part of map / canvas which is currently seen on screen?

推荐答案

现在我可以提请所有10000行,没有任何延迟。这是所有精心设计平局()方法。我有些感动创建对象的操作(如道路,站)出平局()。我看到,特别是 projection.toPixels(GeoPoint对象,点); 是非常昂贵的操作。最后,我设置一个恒定的阿尔法持有手指移动的像素值。它只有在绘制或pixelX运动pixelY大于阿尔法。

Now I can draw all 10000 lines without any lag. It is all about designing draw() method carefully. I moved some object creating operations (like Path, Point) out of draw(). I saw that especially projection.toPixels(geoPoint, point); is very expensive operation. Finally I set an alpha constant which holds the pixel value of finger movement. And it only draws when pixelX or pixelY movement is bigger than alpha.

这篇关于提高谷歌地图的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆