use of com.google.maps.android.data.kml.KmlContainer in project android-maps-utils by googlemaps.
the class KmlDemoActivity method moveCameraToKml.
private void moveCameraToKml(KmlLayer kmlLayer) {
//Retrieve the first container in the KML layer
KmlContainer container = kmlLayer.getContainers().iterator().next();
//Retrieve a nested container within the first container
container = container.getContainers().iterator().next();
//Retrieve the first placemark in the nested container
KmlPlacemark placemark = container.getPlacemarks().iterator().next();
//Retrieve a polygon object in a placemark
KmlPolygon polygon = (KmlPolygon) placemark.getGeometry();
//Create LatLngBounds of the outer coordinates of the polygon
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (LatLng latLng : polygon.getOuterBoundaryCoordinates()) {
builder.include(latLng);
}
int width = getResources().getDisplayMetrics().widthPixels;
int height = getResources().getDisplayMetrics().heightPixels;
getMap().moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), width, height, 1));
}
Aggregations