/** * Adds a DataPolygon to the map as a Polygon * * @param polygonOptions * @param polygon contains coordinates for the Polygon * @return Polygon object created from given DataPolygon */ protected Polygon addPolygonToMap(PolygonOptions polygonOptions, DataPolygon polygon) { // First array of coordinates are the outline polygonOptions.addAll(polygon.getOuterBoundaryCoordinates()); // Following arrays are holes List<List<LatLng>> innerBoundaries = polygon.getInnerBoundaryCoordinates(); for (List<LatLng> innerBoundary : innerBoundaries) { polygonOptions.addHole(innerBoundary); } Polygon addedPolygon = mMap.addPolygon(polygonOptions); addedPolygon.setClickable(polygonOptions.isClickable()); return addedPolygon; }
/** * Toggles the clickability of the polygon based on the state of the View that triggered this * call. * This callback is defined on the CheckBox in the layout for this Activity. */ public void toggleClickability(View view) { if (mMutablePolygon != null) { mMutablePolygon.setClickable(((CheckBox) view).isChecked()); } } }
@Override public void setClickable(boolean clickable) { real.setClickable(clickable); }
/** * Adds a GeoJsonPolygon to the map as a Polygon * * @param polygonStyle contains relevant styling properties for the Polygon * @param polygon contains coordinates for the Polygon * @return Polygon object created from given GeoJsonPolygon */ private Polygon addPolygonToMap(GeoJsonPolygonStyle polygonStyle, GeoJsonPolygon polygon) { PolygonOptions polygonOptions = polygonStyle.toPolygonOptions(); // First array of coordinates are the outline polygonOptions.addAll(polygon.getCoordinates().get(POLYGON_OUTER_COORDINATE_INDEX)); // Following arrays are holes for (int i = POLYGON_INNER_COORDINATE_INDEX; i < polygon.getCoordinates().size(); i++) { polygonOptions.addHole(polygon.getCoordinates().get(i)); } Polygon addedPolygon = mMap.addPolygon(polygonOptions); addedPolygon.setClickable(true); return addedPolygon; }