Android Maps API v2 - 标记旋转的方法? [英] Android Maps API v2 - approaches to marker rotation?

查看:67
本文介绍了Android Maps API v2 - 标记旋转的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将应用从v1 Maps API移植到v2 API,并且遇到了标记问题。



我们需要指向特定地理方向的标记。在V1中,我们可以在绘制时在正确的方向上构建位图指向,但在V2中,标记位图不能更改。



我不确定if最好的方法是在地图旋转时(这听起来像是一个性能问题)销毁和重新构建我们所有的标记,或者尝试自己绘制它们。这可能是通过TileOverlay或通过我们自己的视图,我们坐在地图上。



我不太喜欢这些方法中的任何一种。有没有人尝试过其中任何一种?

更新:

我试图通过我们自己的视图进行绘制,但那太滞后了当地图被拖动时。



我现在正在销毁&重新创建标记,但这是(如预期的)性能问题,需要〜2000mS来更新60个标记。 解析方案

好消息大家! Google已经为地图API添加了轮播功能,因此我们不必再滚动我们自己的实现。

他们还添加了平面标记,我认为它们更相关到原来的问题。展平的标记将始终保持其最初绘制在地图上的方向: https: //developers.google.com/maps/documentation/android/marker#flatten_a_marker



唯一的要求是您参考了最新版Google Play服务。


We're porting an app from the v1 Maps API to the v2 API, and having trouble with markers.

We need markers that point in a specific geographic direction. In V1, we could build the bitmap pointing in the right direction at draw time, but in V2 the marker bitmap can't be changed.

I'm not sure if the best approach is to destroy and re-build all our markers when the map is rotated (which sounds like a performance problem), or to try drawing them all ourselves. That could be via a TileOverlay or via a view of our own that we sat on top of the map.

I don't really like any of these approaches. Has anyone tried any of them ?

UPDATE:

I've tried drawing via a view of our own, but that was far too laggy when the map was dragged.

I'm now destroying & recreating the markers, but that is (as expected) a performance problem, taking ~2000mS to update 60 markers.

解决方案

Good news everyone! Google has added rotation to the Maps API, so we don't have to roll our own implementations anymore.

They have also added flat markers, which I guess is more related to the original question. A flattened marker will always stay in the orientation it was originally drawn on the map: https://developers.google.com/maps/documentation/android/marker#flatten_a_marker

The only requirement is that you reference the latest version of Google Play Services.

这篇关于Android Maps API v2 - 标记旋转的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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