use of com.google.android.libraries.maps.model.Polygon in project android-samples by googlemaps.
the class PolygonDemoActivity method onMapReady.
@Override
public void onMapReady(GoogleMap map) {
// Override the default content description on the view, for accessibility mode.
map.setContentDescription(getString(R.string.polygon_demo_description));
int fillColorArgb = Color.HSVToColor(fillAlphaBar.getProgress(), new float[] { fillHueBar.getProgress(), 1, 1 });
int strokeColorArgb = Color.HSVToColor(strokeAlphaBar.getProgress(), new float[] { strokeHueBar.getProgress(), 1, 1 });
// Create a rectangle with two rectangular holes.
mutablePolygon = map.addPolygon(new PolygonOptions().addAll(createRectangle(CENTER, 5, 5)).addHole(createRectangle(new LatLng(-22, 128), 1, 1)).addHole(createRectangle(new LatLng(-18, 133), 0.5, 1.5)).fillColor(fillColorArgb).strokeColor(strokeColorArgb).strokeWidth(strokeWidthBar.getProgress()).clickable(clickabilityCheckbox.isChecked()));
fillHueBar.setOnSeekBarChangeListener(this);
fillAlphaBar.setOnSeekBarChangeListener(this);
strokeWidthBar.setOnSeekBarChangeListener(this);
strokeHueBar.setOnSeekBarChangeListener(this);
strokeAlphaBar.setOnSeekBarChangeListener(this);
strokeJointTypeSpinner.setOnItemSelectedListener(this);
strokePatternSpinner.setOnItemSelectedListener(this);
mutablePolygon.setStrokeJointType(getSelectedJointType(strokeJointTypeSpinner.getSelectedItemPosition()));
mutablePolygon.setStrokePattern(getSelectedPattern(strokePatternSpinner.getSelectedItemPosition()));
// Move the map so that it is centered on the mutable polygon.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(CENTER, 4));
// Add a listener for polygon clicks that changes the clicked polygon's stroke color.
map.setOnPolygonClickListener(new GoogleMap.OnPolygonClickListener() {
@Override
public void onPolygonClick(Polygon polygon) {
// Flip the red, green and blue components of the polygon's stroke color.
polygon.setStrokeColor(polygon.getStrokeColor() ^ 0x00ffffff);
}
});
}
Aggregations