大佬教程收集整理的这篇文章主要介绍了android – 如何从MapController捕获放大/缩小动画的结尾?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_963_7@mapController.zoomIn() or MapController.zoomOut();
我知道它确实启动了一个动画序列来放大/缩小到下一个级别,但是没有已知的方法可以找到/谷歌搜索等,以找出它何时完成该序列.我需要能够在停止时运行更新命令,以便我的地图正确更新.
我发现通过在调用上面的函数后运行update命令,Projection不是来自缩小级别,而是介于两者之间(所以我无法显示我需要的所有数据).
正如Stack Overflow上其他地方所建议的那样,我的缩放侦听器是一个重写的MapView.dispatchDraw,用于检查自上次以来缩放级别是否已更改.
除此之外,我添加了一个isResizing方法,该方法检查自getLongitudeSpan值停止更改以来时间戳是否超过100毫秒.效果很好.这是代码:
我的第一个Stack Overflow帖子!喔喔!
公共类MapViewWithZoomListener扩展MapView {
privatE int oldZoomLevel = -1; private List<OnClickListener> listeners = new ArrayList<OnClickListener>(); private long resizingLongitudeSpan = getLongitudeSpan(); private long resizingTime = new Date().getTime(); public MapViewWithZoomListener(Context context,String s) { super(context,s); } public MapViewWithZoomListener(Context context,AttributeSet attributeSet) { super(context,attributeSet); } public MapViewWithZoomListener(Context context,AttributeSet attributeSet,int i) { super(context,attributeSet,i); } public Boolean isResizing() { // done resizing if 100ms has elapsed without a change in getLongitudeSpan return (new Date().getTime() - resizingTime < 100); } public void dispatchDraw(Canvas canvas) { super.dispatchDraw(canvas); if (getZoomLevel() != oldZoomLevel) { new AsyncTask() { @Override protected Object doInBACkground(Object... objects) { try { if (getLongitudeSpan() != resizingLongitudeSpan) { resizingLongitudeSpan = getLongitudeSpan(); resizingTime = new Date().getTime(); } Thread.sleep(125); //slightly larger than isMoving threshold } catch (InterruptedException E) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Object o) { super.onPostExecute(o); if (!isResizing() && oldZoomLevel != getZoomLevel()) { oldZoomLevel = getZoomLevel(); invalidate(); for (OnClickListener listener : listeners) { listener.onClick(null); } } } }.execute(); } } public void addZoomListener(OnClickListener listener) { listeners.add(listener); }
以上是大佬教程为你收集整理的android – 如何从MapController捕获放大/缩小动画的结尾?全部内容,希望文章能够帮你解决android – 如何从MapController捕获放大/缩小动画的结尾?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。