我在我的Android应用程序中将Google Maps v1升级到了v2。
v2非常好,但其中一个方法似乎是我生命中最慢的东西。
Projection proj = map.getProjection();
Point point = proj.toScreenLocation(example.m_geopoint);
toScreenLocation(...)非常缓慢,导致应用程序变得无法使用。
每帧可能会更新100次,但在Google Maps v1上表现非常好。
当我在Android控制台中检查时,看到如下提示:
10-06 13:53:04.460: D/dalvikvm(4889): GC_EXPLICIT freed 251K, 14% free 14622K/16839K, paused 3ms+5ms
10-06 13:53:05.859: D/dalvikvm(4889): GC_EXPLICIT freed 252K, 14% free 14622K/16839K, paused 2ms+5ms
10-06 13:53:07.222: D/dalvikvm(4889): GC_EXPLICIT freed 251K, 14% free 14622K/16839K, paused 3ms+6ms
...
当方法被调用时,此消息会一直出现。
v2和v1之间的区别在于:
pointOut = proj.toScreenLocation(geopointIn); // v2
projection.toPixels(geopointIn, pointOut); // v1
而v1似乎是更优化的解决方案。有没有什么方法可以使其更快?这是性能问题吗?