bounding the lat lng with osmdroid similar to LatLngBounds in google maps

后端 未结 2 1178
耶瑟儿~
耶瑟儿~ 2021-01-29 03:17

In my android application I\'m using routing and clustering in osmdroid but I\'m not able to bound the LatLng like we do in google maps with latlngbounds.builder...

for

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-29 04:02

    { 
    IGeoPoint screenTopLeft = mapView.getProjection().fromPixels(0, 0);
                IGeoPoint screenTopRight = mapView.getProjection().fromPixels(mapView.getWidth(), 0);
                IGeoPoint screenBottomLeft = mapView.getProjection().fromPixels(0, mapView.getHeight());
                List iGeoPoints = new ArrayList<>();
                iGeoPoints.add(screenTopRight);
                iGeoPoints.add(screenTopLeft);
                iGeoPoints.add(screenBottomLeft);
                BoundingBox boundingBox = BoundingBox.fromGeoPoints(iGeoPoints);
                if (boundingBox.contains(currentLocation.getLatitude(), currentLocation.getLongitude())) {
                    return true;
                } else {
                    return false;
                }
            }
    

    This will check whether current location is under bound or not.

提交回复
热议问题