Google Maps v2 Projection.toScreenLocation(...)极其缓慢 [英] Google Maps v2 Projection.toScreenLocation(...) extremely slow

查看:187
本文介绍了Google Maps v2 Projection.toScreenLocation(...)极其缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android应用程序中将Google Maps v1升级到v2。

I have upgraded Google Maps v1 to v2 in my Android application.

v2很好等等,但是有一种方法似乎是我生命中最慢的事情。

And v2 was nice and so on BUT one method seems to be the slowest thing in my life.

Projection proj = map.getProjection();
Point point = proj.toScreenLocation(example.m_geopoint);

toScreenLocation(...)速度太慢,所以应用程序的速度变慢,无法使用慢动作。
每次更新的方法可能是100次,但在Google Maps v1上效果非常好。

toScreenLocation(...) is so slow so the application slow downs to unusable slowmotion. The method updated maybe 100 times per frame but that works very very great on Google Maps v1.

当我检查Android Console时,我看到:

And when I check in Android Console I see this:

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
...

此方法被调用时,此消息一直出现。

This message is coming out all the time while the method is called.

v2和v1之间的区别是:

And the difference between v2 and v1 is this:

pointOut = proj.toScreenLocation(geopointIn); // v2
projection.toPixels(geopointIn, pointOut); // v1

v1似乎是更优化的解决方案。有什么方法可以让它更快?这是一个性能问题吗?

And the v1 seems to be more optimized solution. Is there some way to get it faster? Is it a performance bug?

推荐答案

这个答案可能太晚了,但如果其他人遇到同样的问题,像我一样,一种解决方案可能是使用Java的Graphics2D(它几乎与绘制到画布上的效果几乎相同)在自己的服务器上预先渲染图像,然后在应用程序中下载它。您必须将地理点转换为笛卡尔坐标。
在应用程序中,您只需将图像定位为具有LatLngBounds的GroundOverlay: https://developers.google.com/maps/documentation/android/groundoverlay#use_latlngbounds_to_position_an_image

This answers comes probably too late, but if anybody else runs into the same problems, like me, a solution could be to pre-render an image on an own server with Java's Graphics2D (which works almost the same as drawing to the canvas) and download it within the app. You have to convert the geo points into cartesian coordinates. Within the app, you only have to position the image as GroundOverlay with LatLngBounds: https://developers.google.com/maps/documentation/android/groundoverlay#use_latlngbounds_to_position_an_image

并将其添加到地图中...
https://developers.google.com/maps/documentation/android/groundoverlay #change_an_overlay

and add it to the map... https://developers.google.com/maps/documentation/android/groundoverlay#change_an_overlay

对我而言,这种方法工作得非常快。至少与Google Maps V1方法一样快。

For me, this approach works pretty fast. At least as fast as the Google Maps V1 approach.

这篇关于Google Maps v2 Projection.toScreenLocation(...)极其缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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