use of com.google.android.libraries.maps.model.LatLngBounds in project android-maps-utils by googlemaps.
the class ZoomClusteringDemoActivity method onClusterClick.
@Override
public boolean onClusterClick(Cluster<MyItem> cluster) {
// Show a toast with some info when the cluster is clicked.
String title = cluster.getItems().iterator().next().getTitle();
Toast.makeText(this, cluster.getSize() + " (including " + title + ")", Toast.LENGTH_SHORT).show();
// Zoom in the cluster. Need to create LatLngBounds and including all the cluster items
// inside of bounds, then animate to center of the bounds.
// Create the builder to collect all essential cluster items for the bounds.
LatLngBounds.Builder builder = LatLngBounds.builder();
for (ClusterItem item : cluster.getItems()) {
builder.include(item.getPosition());
}
// Animate camera to the bounds
try {
getMap().animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 100));
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
use of com.google.android.libraries.maps.model.LatLngBounds in project android-places-demos by googlemaps.
the class AutocompleteTestActivity method getBounds.
@Nullable
private RectangularBounds getBounds(int resIdSouthWest, int resIdNorthEast) {
String southWest = ((TextView) findViewById(resIdSouthWest)).getText().toString();
String northEast = ((TextView) findViewById(resIdNorthEast)).getText().toString();
if (TextUtils.isEmpty(southWest) && TextUtils.isEmpty(northEast)) {
return null;
}
LatLngBounds bounds = StringUtil.convertToLatLngBounds(southWest, northEast);
if (bounds == null) {
showErrorAlert(R.string.error_alert_message_invalid_bounds);
return null;
}
return RectangularBounds.newInstance(bounds);
}
use of com.google.android.libraries.maps.model.LatLngBounds in project android-places-demos by googlemaps.
the class StringUtil method convertToLatLngBounds.
@Nullable
static LatLngBounds convertToLatLngBounds(@Nullable String southWest, @Nullable String northEast) {
LatLng soundWestLatLng = convertToLatLng(southWest);
LatLng northEastLatLng = convertToLatLng(northEast);
if (soundWestLatLng == null || northEast == null) {
return null;
}
return new LatLngBounds(soundWestLatLng, northEastLatLng);
}
Aggregations