我试图检查用户是否处于结束位置(经纬度对象)的边界,即使当前位置=结束位置,contains函数总是返回false。所有坐标都正确更新。我是否错误地使用了LatLngBounds?任何想法如何解决它或使用界限的替代?LatLng Bounds contains()总是返回false
protected void changeStep() throws JSONException {
Log.i(TAG, " =========== changeStep ========= ");
int i = 0;
while (i < routes.size()) {
//coordinates for end location
Double latEndLoc = routes.get(i).endLocation.lat;
Double lngEndLoc = routes.get(i).endLocation.lng;
LatLng endLoc = new LatLng(latEndLoc,lngEndLoc);
//setting bounds for end location
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(endLoc);
LatLngBounds bounds = builder.build();
Log.i("endLoc", endLoc.toString());
Log.i("bounds center", bounds.getCenter().toString());
Log.i("currentLoc", currentLocation.toString());
//checking if users current location is within bounds of end location
if (bounds.contains(currentLocation)) {
Log.i(TAG, " =========== enteredIfBranch ========= ");
setText(i + 1);
return;
}
i++;
}
}
除了这个事实,你不能做任何事情,同积1分,你怎么确定你考虑终点的“界限”?你至少需要2分 – tyczj