OnCameraChangeListener不响应不够的 - 有另一种方式? [英] OnCameraChangeListener is not responsive enough - is there another way?

查看:1356
本文介绍了OnCameraChangeListener不响应不够的 - 有另一种方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我移植了一层我有一个V1映射到V2。该层绘制一个自定义的控制在地图上,并作为地图移动时,它必须留在地方,其当前地理位置(W /正确的比例)。

I am porting a layer I have in a v1 map to v2. The layer draws a custom control on the map and, as the map moves, it must stay in place on its current geolocation (w/ the correct scale).

有人建议我使用 onCameraChange 传达给我的层(自定义视图,在地图的上方),相机被平移或缩放和更新适当的层。

It had been suggested to me to use onCameraChange to communicate to my layer (a custom view, on top of the map) that the camera was panning or zooming and update the layer appropriately.

我的问题是, onCameraChange 只调用的相机已经移动 - 而不是在。这是,以不响应不够。有另一种方式来实现这一目标?

My problem is that onCameraChange is only called after the camera has been moved - not during. It is therefor not responsive enough. Is there another way to achieve this?

推荐答案

试着从包装类似RelativeLayout的继承您的自定义类中的MapFragment(或图形页面)。然后你就可以覆盖onInterceptTouchEvent或dispatchTouchEvent在自定义布局,并从那里移动您的自定义视图。我尝试过自己,它会给你肯定更比回调与onCameraChange。

Try to wrap the MapFragment (or MapView) inside your custom class inherited from something like RelativeLayout. Then you can override onInterceptTouchEvent or dispatchTouchEvent in that custom layout and move your custom view from there. I tried it myself and it will give you definitely more callbacks than with the onCameraChange.

您还可以看看我的答案在这里:
<一href="http://stackoverflow.com/questions/14123243/google-maps-api-v2-custom-infowindow-like-in-original-android-google-maps/15040761#15040761">Google像原生Android谷歌地图API V2定制的信息窗口地图
我正在处理的东西有点不同(我试图避免移动自定义视图在地图上,但我只需要在一个信息窗口某些按钮),但我用这种包装的布局也有。

You can also take a look at my answer here:
Google maps api v2 custom infowindow like in original android google maps
I was dealing with something little bit different (I tried to avoid moving custom views over the map but I needed only some buttons on an infoWindow), but I used this wrapping layout there too.

这篇关于OnCameraChangeListener不响应不够的 - 有另一种方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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