2017-05-03 6 views
0

내 안드로이드 애플리케이션에서 osmdroid에서 라우팅 및 클러스터링을 사용하고 있지만 latlngbound.builder가있는 Google지도에서 LatLng를 바인딩 할 수는 없습니다. . 내가 osmdroid와 동일한 작업을 수행 할Google지도에서 LatLngBounds와 비슷한 osmdroid로 lat lng를 경계합니다.

LatLng longlat = new LatLng(lat, log); 

LatLngBounds.Builder builder = new LatLngBounds.Builder(); 
builder.include(longlat); 

예를

을 위해.

+0

당신은 osmdroid에 대해 이야기하고 있습니까? 적어도 사용중인 라이브러리에 대해 언급하십시오. – scai

+0

예 osmdroid에 대해 이야기하고 있습니다. – srk

답변

1

Google지도 LatLngBounds는 osmdroid에서 BoundingBox가됩니다 (어느 정도).

LatLngBounds.including 메서드와 직접적으로 동일한 기능을 제공하지 않습니다 (예,이 메서드를 구현하는 것이 좋습니다).

하지만 BoundingBox.fromGeoPoints는 다양한 요구를 충족합니다.

0
{ 
IGeoPoint screenTopLeft = mapView.getProjection().fromPixels(0, 0); 
      IGeoPoint screenTopRight = mapView.getProjection().fromPixels(mapView.getWidth(), 0); 
      IGeoPoint screenBottomLeft = mapView.getProjection().fromPixels(0, mapView.getHeight()); 
      List<IGeoPoint> 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; 
      } 
     } 

현재 위치가 바운드인지 여부를 확인합니다.