- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我需要限制我的用户可以在 map View 中导航到的区域(除非他们会得到一个空白屏幕!)。我创建了一个扩展 mapview 并覆盖 onTouchEvent 的类。我正在检测“ACTION_UP” Action 并检查此处的坐标并在必要时重新定位 map 。一切正常,直到用户“抛出” map 。我可以检测到“向上”和那个点的屏幕坐标,但 map 仍在移动,所以我检测到的坐标不正确。
我需要知道屏幕停止移动时的位置!
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_UP ) {
//get coords of screen corners and calculate if the map is still in view.
}
我一直在寻找这个问题的答案,但很多人都在问这个问题,但似乎没有任何解决方案?
有没有人设法做到这一点?
Bex
最佳答案
我用来覆盖 MapView 的 computeScroll() 方法:
/**
* checks restriction on pan bounds and locks the map. if the map is locked
* (via mapController.getCenter()) this method returns true
*
* @return TRUE if map has been locked
*/
private boolean restrictPanOnBounds() {
if (this.minLatitudeE6 == Integer.MIN_VALUE)
return false;
GeoPoint center = getMapCenter();
int cLat = center.getLatitudeE6();
int cLong = center.getLongitudeE6();
Integer nLat = null, nLong = null;
if (cLat < this.minLatitudeE6)
nLat = this.minLatitudeE6;
else if (cLat > this.maxLatitudeE6)
nLat = this.maxLatitudeE6;
if (cLong < this.minLongitudeE6)
nLong = this.minLongitudeE6;
else if (cLong > this.maxLongitudeE6)
nLong = this.maxLongitudeE6;
if (nLat != null || nLong != null) {
getController().setCenter(new GeoPoint(nLat != null ? nLat : cLat, nLong != null ? nLong : cLong));
return true;
} else {
return false;
}
}
@Override
public void computeScroll() {
if (restrictPanOnBounds())
getController().stopPanning();
else
super.computeScroll();
}
它对于简单的移动 Action 非常有效( map 停止并没有跳回)但是在 throw 时仍然有一个“有趣的”倾斜效果......
关于Android Get Mapview on Fling 停止动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5950429/
我知道使用 GET 和 SET 函数的公共(public)变量的缺点/私有(private)变量的优点,但目前我正在使用 Ogre3D 开发自己的第一个“真实”游戏(C++)..同时,我有时需要 6-
我正在开发一个 GSM/GPRS 应用程序,它将每 10 秒报告一些值。我必须使用的 SIM 卡每月只有 15MB 可用数据。我使用的是 SIM900 GSM 芯片供您引用。 我到达服务器的方式是通过
这三者有什么区别:gets - 它获取带有 '\n' 的行gets.chomp - 它得到一行,但删除 '\n' 这样对吗? gets.chomp! 怎么样? 最佳答案 gets - 它得到一个末尾带
问题和我现在遇到的问题 脚本 顺便说一句,评论是挪威语的,如果它们看起来很奇怪哈哈 Connect-AzureAD #variabel $Users = Get-AzureADUser -All:$t
我现在面临的问题是获取一个 URL,如下所示: www.example.com/example.php?url=www.google.com 现在的问题是,如果我的网址中有一个 get,如下所示: w
我有一个 queryString 传递给 servlet 的 doGet() 方法,如下所示: count=9&preId0=-99&objId0=-99&preId1=-99&objId1=-99&
这是我在 Django 模板中的代码: {% for tag in tags %} {{ tag }} {% endfor %} 在view.py中: def tag_find(
我正在尝试在express.js中为我的网络应用程序创建一个路由系统,我需要知道是否需要使用app.get/post/put/delete.apply以编程方式设置多个功能对于一条路线。 也是如此 a
我正在通过示例查看 A.Mele Django,第 1 章 def post_list(request, category=None): object_list = Post.publishe
如果我想找到与IIS站点或应用程序关联的目录,我该怎么做? 我似乎无法从Get-Website和Get-WebApplication的对象的任何属性中找到任何允许我这样做的东西。 最佳答案 只需查看一
不知道发生了什么。当我执行以下代码时......它运行良好......但它产生了错误。如果我将以下内容粘贴到我的浏览器地址栏中并点击它,我会得到一个 URL。如果我通过 KRL http:get 输入
Curl 提供了一系列不同的带有 X 前缀的 http 方法调用,但也提供了不带 X 的相同方法。我两种都试过了,但我似乎无法弄清楚其中的区别。有人可以快速向我解释这两种操作有何不同吗? 最佳答案 默
request.GET.get 是什么意思?我在 Django 中看到类似的东西 page = request.GET.get('page', 1) 我认为它与类似的东西有关 « 它们是如
我正在从我的 Angular2 站点查询一些 Elasticsearch 服务器。为了帮助提高安全性,我们希望锁定对 GET 请求的访问权限。 Elasticsearch 支持带主体的 GET,但我在
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 4年前关闭。 Improve t
调用 HTable.get(List) 返回的 Result 数组的顺序是什么? ? 我的意思是,假设与输入列表的顺序相同是否正确? 最佳答案 结果数组中的顺序将与输入列表的顺序相同。与批处理方法一样
所以我有一个看起来像这样的 JSON 数组: var myData = { foo : { biz : 'baz', fig : 'tree' } }
我正在学习 Ajax、javascript 和 html,并且有一个应用程序可以触发“get”请求,然后再触发另一个“get”请求。这些请求是用户按下按钮的结果。在我的 servlet 中,我使用 T
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 6 年前。 Improv
运行以下 cmdlet 适用于组成员(Amer 域中的组)中的所有用户,无论列出的用户位于哪个域: Get-ADGroupMember -Server amer 但是,当尝试通过管道传输到 Get-
我是一名优秀的程序员,十分优秀!