public static Projection convert(LatLngBounds bound) { return new BaiduProjection( new VisibleRegion( new com.car2go.maps.model.LatLngBounds( BaiduToModelConverter.convert(bound.southwest), BaiduToModelConverter.convert(bound.northeast) ) ) ); } }
@Override public com.car2go.maps.model.LatLngBounds map(LatLngBounds input) { LatLng southWest = AnyMapAdapter.adapt(input.southwest); LatLng northEast = AnyMapAdapter.adapt(input.northeast); return new com.car2go.maps.model.LatLngBounds(southWest, northEast); }
/** * @return new instance of {@link LatLngBounds} * @throws IllegalStateException if less than 2 unique points were specified */ public LatLngBounds build() { if (Double.isNaN(southWestLongitude)) { throw new IllegalStateException("No included points"); } return new LatLngBounds( new LatLng(southWestLattitude, southWestLongitude), new LatLng(northEastLattitude, northEastLongitude) ); }
@Override public Projection getProjection() { org.osmdroid.views.Projection projection = map.getProjection(); return new OsmProjection( new VisibleRegion( new LatLngBounds( new LatLng( projection.getSouthWest().getLatitude(), projection.getSouthWest().getLongitude() ), new LatLng( projection.getNorthEast().getLatitude(), projection.getNorthEast().getLongitude() ) ) ) ); }
@Test public void testMoveCameraToBounds() throws Exception { // Given CameraUpdateHandler handler = new CameraUpdateHandler(map); final LatLngBounds bounds = new LatLngBounds( new LatLng(10, 10), new LatLng(20, 20) ); OsmCameraUpdate cameraUpdate = new OsmCameraUpdate.Builder() .bounds(bounds) .build(); // When handler.moveCamera(cameraUpdate); // Then verify(mapController).setCenter(eq( toGeoPoint(bounds.getCenter()) )); verify(mapController).zoomToSpan( eq((int) (10 * 1e6)), eq((int) (10 * 1e6)) ); }
@Test public void testMap() throws Exception { // Given LatLngBoundsMapper mapper = new LatLngBoundsMapper(); LatLngBounds input = new LatLngBounds( new LatLng(10, 10), new LatLng(20, 20) ); // When com.google.android.gms.maps.model.LatLngBounds output = mapper.map(input); // Then TestUtil.assertEquals( input.southwest, output.southwest ); TestUtil.assertEquals( input.northeast, output.northeast ); }