检查标记是圆的半径内 [英] Check if marker is inside circle radius

查看:151
本文介绍了检查标记是圆的半径内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,如果给定的标志物是一个圆的半径内。

I'm trying to know if a given marker is inside a circle radius.

在JavaScript中,我可以这样做:

In javascript, i can do something like:

google.maps.geometry.spherical.computeDistanceBetween(latLngCircleCenter, latLngPoint);

但在Android中,利用地图-V2,我是stucked。

But in android, using maps-v2, i'm stucked.

推荐答案

大量的调查研究后,我发现了一个很简单的解决办法:

After a lot of research, i found a very simple solution:

float[] distance = new float[2];

Location.distanceBetween( marker.getPosition().latitude, marker.getPosition().longitude,
    circle.getCenter().latitude, circle.getCenter().longitude, distance);

if( distance[0] > circle.getRadius()  ){
    Toast.makeText(getBaseContext(), "Outside", Toast.LENGTH_LONG).show();
} else {
    Toast.makeText(getBaseContext(), "Inside", Toast.LENGTH_LONG).show();
}

我测试这一点,它的工作。可有人测试过,并给予反馈吗?

I'm testing this and it's working. Can someone test too and give the feedback here?

这篇关于检查标记是圆的半径内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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