/** * Gets a new PolygonOptions object containing styles for the GeoJsonPolygon * * @return new PolygonOptions object */ public PolygonOptions toPolygonOptions() { PolygonOptions polygonOptions = new PolygonOptions(); polygonOptions.fillColor(mPolygonOptions.getFillColor()); polygonOptions.geodesic(mPolygonOptions.isGeodesic()); polygonOptions.strokeColor(mPolygonOptions.getStrokeColor()); polygonOptions.strokeWidth(mPolygonOptions.getStrokeWidth()); polygonOptions.visible(mPolygonOptions.isVisible()); polygonOptions.zIndex(mPolygonOptions.getZIndex()); polygonOptions.clickable(mPolygonOptions.isClickable()); return polygonOptions; }
/** * 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; }
public Builder<T> add(LatLng point) { this.polygonOptions.add(point); return this; }
public Builder() { polygonOptions.strokeWidth(STROKE_WIDTH); polygonOptions.strokeColor(STROKE_COLOR); }
/** *Creates a new PolygonOption from given properties of an existing PolygonOption * @param originalPolygonOption An existing PolygonOption instance * @param isFill Whether the fill for a polygon is set * @param isOutline Whether the outline for a polygon is set * @return A new PolygonOption */ private static PolygonOptions createPolygonOptions (PolygonOptions originalPolygonOption, boolean isFill, boolean isOutline) { PolygonOptions polygonOptions = new PolygonOptions(); if (isFill) { polygonOptions.fillColor(originalPolygonOption.getFillColor()); } if (isOutline) { polygonOptions.strokeColor(originalPolygonOption.getStrokeColor()); polygonOptions.strokeWidth(originalPolygonOption.getStrokeWidth()); } return polygonOptions; }
triangle.add(new LatLng(28.06025,-82.41030)); // Should match first point mMap.addPolygon(new PolygonOptions() .addAll(triangle) .fillColor(Color.BLUE - ALPHA_ADJUSTMENT) .strokeColor(Color.BLUE) .strokeWidth(5)); mMap.addPolygon(new PolygonOptions() .addAll(simplifiedTriangle) .fillColor(Color.YELLOW - ALPHA_ADJUSTMENT) .strokeColor(Color.YELLOW) .strokeWidth(5)); mMap.addPolygon(new PolygonOptions() .addAll(oval) .fillColor(Color.BLUE - ALPHA_ADJUSTMENT) .strokeColor(Color.BLUE) .strokeWidth(5)); mMap.addPolygon(new PolygonOptions() .addAll(simplifiedOval) .fillColor(Color.YELLOW - ALPHA_ADJUSTMENT) .strokeColor(Color.YELLOW) .strokeWidth(5));
/** * Add a Polyline and a Polygon to the map. * The Polyline connects Melbourne, Adelaide and Perth. The Polygon is located in the Northern * Territory (Australia). */ private void addPolyObjects() { mMap.addPolyline((new PolylineOptions()) .add(MELBOURNE, ADELAIDE, PERTH) .color(Color.GREEN) .width(5f)); mMap.addPolygon(new PolygonOptions() .add(POLYGON) .fillColor(Color.CYAN) .strokeColor(Color.BLUE) .strokeWidth(5)); }
mMutablePolygon = 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(mStrokeWidthBar.getProgress()) .clickable(mClickabilityCheckbox.isChecked()));
count++; googleMap.addPolygon( new PolygonOptions() .fillColor(polygon.getFillColor()) .strokeColor(polygon.getUiOptions().getColor()) .strokeWidth(polygon.getUiOptions().getWidth()) .strokePattern(getStrokePattern(polygon.getUiOptions().getStrokePattern())) .zIndex(polygon.getUiOptions().getzIndex()) .add(polygon.getPoints()) ); for (LatLng latLng : polygon.getPoints()) {
/** * Adds a KML Polygon to the map as a Polygon by combining the styling and coordinates * * @param polygon contains coordinates for the Polygon * @param style contains relevant styling properties for the Polygon * @return Polygon object */ private Polygon addPolygonToMap(KmlPolygon polygon, KmlStyle style, KmlStyle inlineStyle) { PolygonOptions polygonOptions = style.getPolygonOptions(); polygonOptions.addAll(polygon.getOuterBoundaryCoordinates()); for (ArrayList<LatLng> innerBoundary : polygon.getInnerBoundaryCoordinates()) { polygonOptions.addHole(innerBoundary); } if (inlineStyle != null) { setInlinePolygonStyle(polygonOptions, inlineStyle); } else if (style.isPolyRandomColorMode()) { polygonOptions.fillColor(KmlStyle.computeRandomColor(polygonOptions.getFillColor())); } return mMap.addPolygon(polygonOptions); }
@Override public <T> void addPolygon(AirMapPolygon<T> polygon) { try { JSONArray array = new JSONArray(); for (LatLng point : polygon.getPolygonOptions().getPoints()) { JSONObject json = new JSONObject(); json.put("lat", point.latitude); json.put("lng", point.longitude); array.put(json); } webView.loadUrl(String.format(Locale.US, "javascript:addPolygon(" + array.toString() + ", %1$d, %2$d, %3$d, %4$d);", polygon.getId(), (int) polygon.getPolygonOptions().getStrokeWidth(), polygon.getPolygonOptions().getStrokeColor(), polygon.getPolygonOptions().getFillColor())); } catch (JSONException e) { Log.e(TAG, "error constructing polyline JSON", e); } }
public void testDefaultGetPolygonOptions() throws Exception { assertEquals(Color.TRANSPARENT, polygonStyle.toPolygonOptions().getFillColor()); assertFalse(polygonStyle.toPolygonOptions().isGeodesic()); assertEquals(Color.BLACK, polygonStyle.toPolygonOptions().getStrokeColor()); assertEquals(10.0f, polygonStyle.toPolygonOptions().getStrokeWidth()); assertTrue(polygonStyle.isVisible()); assertEquals(0.0f, polygonStyle.toPolygonOptions().getZIndex()); } }
new PolygonOptions().add(new LatLng(40.748429, -73.984573), new LatLng(40.753393, -73.996311), new LatLng(40.758393, -73.992705), new LatLng(40.753484, -73.980882)) .strokeColor(Color.BLUE);
public Builder<T> strokeColor(int color) { polygonOptions.strokeColor(color); return this; }
/** * Sets the fill color of the Polygon as a 32-bit ARGB color * * @param fillColor fill color value of the Polygon */ public void setPolygonFillColor(int fillColor) { mPolygonOptions.fillColor(fillColor); } }
/** * Sets the stroke width of the Polygon in screen pixels * * @param strokeWidth stroke width value of the Polygon */ public void setPolygonStrokeWidth(float strokeWidth) { mPolygonOptions.strokeWidth(strokeWidth); }
/** * Creates a new PolygonStyle object */ public GeoJsonPolygonStyle() { mPolygonOptions = new PolygonOptions(); }
setInlinePolygonStyle(polygonOptions, inlineStyle); } else if (style.isPolyRandomColorMode()) { polygonOptions.fillColor(KmlStyle.computeRandomColor(polygonOptions.getFillColor()));
/** * Gets the fill color of the GeoJsonPolygon as a 32-bit ARGB color * * @return fill color of the GeoJsonPolygon */ public int getFillColor() { return mPolygonOptions.getFillColor(); }
/** * 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; }