在地图上的区域切换在图形页面的Andr​​oid SDK [英] On Map Region Change in MapView Android Sdk

查看:80
本文介绍了在地图上的区域切换在图形页面的Andr​​oid SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在执行中Android的一个地图包的应用程序。我是很新的SDK。我的问题是我需要火灾的方法,当地图区域改变。你们可否请您让我知道是有可能触发一个方法,当区域被改变了吗?

I am implementing a Map Kit based application in Android. I was very new to this sdk. My problem is that I need to fire a method when the Map Region changed. Can you guys please let me know is it possible to fire a method when the region is changed?

推荐答案

在地图区域将发生变化时,地图上进行平移或缩放方法,但你无法从这种方法获得的任何信息,因此您可以通过OnDraw的方法DOIT。 要做到这一点,你必须继承的MapView和覆盖的OnDraw方法。

the map region will change when the map perform pan or zoom methods but you cannot obtain any info from this methods, so you can doit through the onDraw method. To achieve this you have to subclass the MapView and overrides the onDraw method.

如果你这样做,你可以得到四个坐标限制显示区域,用投影类retrieveing​​坐标每一个点(左上[0,0],右上[宽度0],左下角[ 0,高度]和右下角[宽度,高度])。

if you do this you can obtain the four coordinates that limits the region displayed, with Projection class retrieveing coordinates for each point ( top-left[0,0], top-right[width-0], bottom-left[0,height] and bottom-right[width,height] ).

例如,在第一OnDraw中:你这四个坐标,GeoPoint对象[4]初始化 在OnDraw中的第二次运行你会得到新的四坐标的GeoPoint [4]最后, 所以在这里,你可以比较的区域。

in example, in the first onDraw: you get this four coordinates, GeoPoint[4] init in the second run of onDraw you get the new four coordinates, GeoPoint[4] end, so here you can compare the regions.

这是一个昂贵的操作,因此延迟机制将有助于放缓的变化检测...

this is a expensive operation so a delay mechanism will be helpful to slowdown the changes detection...

这篇关于在地图上的区域切换在图形页面的Andr​​oid SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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