Otu*_*uyh 14 android google-maps android-maps-v2
我想知道给定的标记是否在圆半径内.
在javascript中,我可以做类似的事情:
google.maps.geometry.spherical.computeDistanceBetween(latLngCircleCenter, latLngPoint);
Run Code Online (Sandbox Code Playgroud)
但是在android中,使用maps-v2,我被困住了.

Otu*_*uyh 42
经过大量的研究,我找到了一个非常简单的解决方案:
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();
}
Run Code Online (Sandbox Code Playgroud)
我正在测试它,它正在工作.有人也可以测试并在此提供反馈吗?
| 归档时间: |
|
| 查看次数: |
15018 次 |
| 最近记录: |