/** * Given a set of four latLng coordinates, creates a LatLng Bound * * @param north North coordinate of the bounding box * @param south South coordinate of the bounding box * @param east East coordinate of the bounding box * @param west West coordinate of the bounding box */ private static LatLngBounds createLatLngBounds(Double north, Double south, Double east, Double west) { LatLng southWest = new LatLng(south, west); LatLng northEast = new LatLng(north, east); return new LatLngBounds(southWest, northEast); } }
@JavascriptInterface public void getBoundsCallback( double neLat, double neLng, double swLat, double swLng) { final LatLngBounds bounds = new LatLngBounds(new LatLng(swLat, swLng), new LatLng(neLat, neLng)); handler.post(new Runnable() { @Override public void run() { onMapBoundsCallback.onMapBoundsReady(bounds); } }); }
/** * Parses a bounding box given as a JSONArray of 4 elements in the order of lowest values for * all axes followed by highest values. Axes order of a bounding box follows the axes order of * geometries. * * @param coordinates array of 4 coordinates * @return LatLngBounds containing the coordinates of the bounding box * @throws JSONException if the bounding box could not be parsed */ private static LatLngBounds parseBoundingBox(JSONArray coordinates) throws JSONException { // Lowest values for all axes LatLng southWestCorner = new LatLng(coordinates.getDouble(1), coordinates.getDouble(0)); // Highest value for all axes LatLng northEastCorner = new LatLng(coordinates.getDouble(3), coordinates.getDouble(2)); return new LatLngBounds(southWestCorner, northEastCorner); }
public void testGetBoundingBox() throws Exception { assertEquals(new LatLngBounds(new LatLng(-80, -150), new LatLng(80, 150)), mLayer.getBoundingBox()); }
public void testGetBoundingBox() { feature = new GeoJsonFeature(null, null, null, null); assertNull(feature.getBoundingBox()); LatLngBounds boundingBox = new LatLngBounds(new LatLng(-20, -20), new LatLng(50, 50)); feature = new GeoJsonFeature(null, null, null, boundingBox); assertEquals(boundingBox, feature.getBoundingBox()); }
/** * Includes this point for building of the bounds. The bounds will be extended in a * minimum way to include this point. * <p/> * More precisely, it will consider extending the bounds both in the eastward and westward * directions (one of which may cross the antimeridian) and choose the smaller of the two. * In the case that both directions result in a LatLngBounds of the same size, this will * extend it in the eastward direction. For example, adding points (0, -179) and (1, 179) * will create a bound crossing the 180 longitude. * * @param point A {@link LatLng} to be included in the bounds. * @return This builder object with a new point added. */ public Builder include(LatLng point) { if (bounds == null) { bounds = new LatLngBounds(point, point); } else { bounds = bounds.including(point); } return this; } }
@Override public com.google.android.gms.maps.model.LatLngBounds map(LatLngBounds input) { LatLng southWest = AnyMapAdapter.adapt(input.southwest); LatLng northEast = AnyMapAdapter.adapt(input.northeast); return new com.google.android.gms.maps.model.LatLngBounds(southWest, northEast); }
/** * Given a set of four latLng coordinates, creates a LatLng Bound * * @param north North coordinate of the bounding box * @param south South coordinate of the bounding box * @param east East coordinate of the bounding box * @param west West coordinate of the bounding box */ private static LatLngBounds createLatLngBounds(Double north, Double south, Double east, Double west) { LatLng southWest = new LatLng(south, west); LatLng northEast = new LatLng(north, east); return new LatLngBounds(southWest, northEast); } }
/** * Returns a new {@link LatLngBounds} that extends this {@link LatLngBounds} to include the * given {@link LatLng}. This will return the smallest LatLngBounds that contains both this * and the extra point. * <p/> * In particular, it will consider extending the bounds both in the eastward and westward * directions (one of which may cross the antimeridian) and choose the smaller of the two. In * the case that both directions result in a LatLngBounds of the same size, this will extend * it in the eastward direction. * * @param point a {@link LatLng} to be included in the new bounds * @return A new {@link LatLngBounds} that contains this and the extra point. */ public LatLngBounds including(LatLng point) { double latMin = Math.min(southwest.latitude, point.latitude); double latMax = Math.max(northeast.latitude, point.latitude); double lonMin = southwest.longitude; double lonMax = northeast.longitude; if (!containsLongitude(point.longitude)) { if ((southwest.longitude - point.longitude + 360.0) % 360.0 < (point.longitude - northeast.longitude + 360.0D) % 360.0D) { lonMin = point.longitude; } else { lonMax = point.longitude; } } return new LatLngBounds(new LatLng(latMin, lonMin), new LatLng(latMax, lonMax)); }
public void routeStartAnimation(LatLng northeast, LatLng southwest) { mTracker.send(new HitBuilders.EventBuilder() .setCategory("Action") .setAction("RouteCreated_on_GoogleMap") .build()); LatLngBounds grenzen = new LatLngBounds(southwest, northeast); map.animateCamera(CameraUpdateFactory.newLatLngBounds(grenzen, 100)); listHandler.sendEmptyMessageDelayed(11, 3000); }
@Override public void updateMapZoomAndRegion(final LatLng northeastLatLng, final LatLng southwestLatLng) { getActivity().runOnUiThread(() -> { mapOverlayLayout.animateCamera(new LatLngBounds(southwestLatLng, northeastLatLng)); mapOverlayLayout.setOnCameraIdleListener(() -> mapOverlayLayout.drawStartAndFinishMarker()); }); }
/** * Parses a bounding box given as a JSONArray of 4 elements in the order of lowest values for * all axes followed by highest values. Axes order of a bounding box follows the axes order of * geometries. * * @param coordinates array of 4 coordinates * @return LatLngBounds containing the coordinates of the bounding box * @throws JSONException if the bounding box could not be parsed */ private static LatLngBounds parseBoundingBox(JSONArray coordinates) throws JSONException { // Lowest values for all axes LatLng southWestCorner = new LatLng(coordinates.getDouble(1), coordinates.getDouble(0)); // Highest value for all axes LatLng northEastCorner = new LatLng(coordinates.getDouble(3), coordinates.getDouble(2)); return new LatLngBounds(southWestCorner, northEastCorner); }
routeBounds = new LatLngBounds(newLimitSouthWestLatLng, newLimitNorthEastLatLng);
LatLngBounds bounds = new LatLngBounds(topLeft, bottomRight); PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); builder.setLatLngBounds(bounds);
@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.car2go.maps.model.LatLngBounds output = mapper.map(input); // Then TestUtil.assertEquals( input.southwest, output.southwest ); TestUtil.assertEquals( input.northeast, output.northeast ); }