@Override public <T> void removePolygon(AirMapPolygon<T> polygon) { Polygon nativePolygon = polygon.getGooglePolygon(); if (nativePolygon != null) { nativePolygon.remove(); } }
/** * 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; }
@Test public void testDelegateMethods() throws Exception { // Given Polygon polygon = mock(Polygon.class); PolygonAdapter polygonAdapter = new PolygonAdapter(polygon); // When polygonAdapter.setVisible(true); polygonAdapter.setHoles(Collections.<List<LatLng>>emptyList()); polygonAdapter.getPoints(); polygonAdapter.remove(); // Then verify(polygon).setVisible(eq(true)); verify(polygon).setHoles(anyList()); verify(polygon).getPoints(); verify(polygon).remove(); }
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (mMutablePolygon == null) { return; } if (seekBar == mFillHueBar) { mMutablePolygon.setFillColor(Color.HSVToColor( Color.alpha(mMutablePolygon.getFillColor()), new float[]{progress, 1, 1})); } else if (seekBar == mFillAlphaBar) { int prevColor = mMutablePolygon.getFillColor(); mMutablePolygon.setFillColor(Color.argb( progress, Color.red(prevColor), Color.green(prevColor), Color.blue(prevColor))); } else if (seekBar == mStrokeHueBar) { mMutablePolygon.setStrokeColor(Color.HSVToColor( Color.alpha(mMutablePolygon.getStrokeColor()), new float[]{progress, 1, 1})); } else if (seekBar == mStrokeAlphaBar) { int prevColorArgb = mMutablePolygon.getStrokeColor(); mMutablePolygon.setStrokeColor(Color.argb( progress, Color.red(prevColorArgb), Color.green(prevColorArgb), Color.blue(prevColorArgb))); } else if (seekBar == mStrokeWidthBar) { mMutablePolygon.setStrokeWidth(progress); } }
polygon.setVisible(isVisible); if (hasDrawOrder) { polygon.setZIndex(drawOrder);
@Override public void setVisible(boolean visible) { polygon.setVisible(visible); }
@Override public void setHoles(List<? extends List<LatLng>> holes) { real.setHoles(holes); }
@Override public List<LatLng> getPoints() { return real.getPoints(); }
@Override public void setFillColor(int fillColor) { real.setFillColor(fillColor); }
@Override public int getFillColor() { return real.getFillColor(); }
@Override public void setVisible(boolean visible) { real.setVisible(visible); }
@Override public void setHoles(List<List<LatLng>> holes) { polygon.setHoles(mapHoles(holes)); }
@Override public List<LatLng> getPoints() { return AnyMapAdapter.adaptList(com.google.android.gms.maps.model.LatLng.class, polygon.getPoints()); }
protected void testePolygon(GoogleMap map) { PolygonOptions p = new PolygonOptions(); p.add(new LatLng(-23.564391, -46.651717)); p.add(new LatLng(-23.565391, -46.652717)); p.add(new LatLng(-23.564282, -46.654337)); p.add(new LatLng(-23.563114, -46.653283)); // p.add(new LatLng(-23.564391, -46.651717)); p.strokeColor(Color.GREEN); p.fillColor(Color.RED); Polygon polygon = map.addPolygon(p); polygon.setFillColor(Color.YELLOW); }
/** * Removes all given Features from the map and clears all stored features. * * @param features features to remove */ protected static void removeFeatures(HashMap<Feature, Object> features) { // Remove map object from the map for (Object mapObject : features.values()) { if (mapObject instanceof Marker) { ((Marker) mapObject).remove(); } else if (mapObject instanceof Polyline) { ((Polyline) mapObject).remove(); } else if (mapObject instanceof Polygon) { ((Polygon) mapObject).remove(); } } }
/** * Adds a single geometry object to the map with its specified style * * @param geometry defines the type of object to add to the map * @param style defines styling properties to add to the object when added to the map * @return the object that was added to the map, this is a Marker, Polyline, Polygon or an array * of either objects */ private Object addToMap(KmlPlacemark placemark, KmlGeometry geometry, KmlStyle style, KmlStyle inlineStyle, boolean isVisible) { String geometryType = geometry.getGeometryType(); if (geometryType.equals("Point")) { Marker marker = addPointToMap(placemark, (KmlPoint) geometry, style, inlineStyle); marker.setVisible(isVisible); return marker; } else if (geometryType.equals("LineString")) { Polyline polyline = addLineStringToMap((KmlLineString) geometry, style, inlineStyle); polyline.setVisible(isVisible); return polyline; } else if (geometryType.equals("Polygon")) { Polygon polygon = addPolygonToMap((KmlPolygon) geometry, style, inlineStyle); polygon.setVisible(isVisible); return polygon; } else if (geometryType.equals("MultiGeometry")) { return addMultiGeometryToMap(placemark, (KmlMultiGeometry) geometry, style, inlineStyle, isVisible); } return null; }
/** * 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()); } } }
/** * Given a Marker, Polyline, Polygon or an array of these and removes it from the map * * @param mapObject map object or array of map objects to remove from the map */ public static void removeFromMap(Object mapObject) { if (mapObject instanceof Marker) { ((Marker) mapObject).remove(); } else if (mapObject instanceof Polyline) { ((Polyline) mapObject).remove(); } else if (mapObject instanceof Polygon) { ((Polygon) mapObject).remove(); } else if (mapObject instanceof ArrayList) { for (Object mapObjectElement : (ArrayList) mapObject) { removeFromMap(mapObjectElement); } } }
@Override public void setClickable(boolean clickable) { real.setClickable(clickable); }
@Override public void remove() { polygon.remove(); }