/** * Adds a provided feature to the map * * @param feature feature to add to map */ protected void addFeature(Feature feature){ mRenderer.addFeature(feature); }
/** * Removes a GeoJsonFeature from the map if its geometry property is not null * * @param feature feature to remove from map */ public void removeFeature(GeoJsonFeature feature) { // Check if given feature is stored super.removeFeature(feature); if (super.getFeatures().contains(feature)) { feature.deleteObserver(this); } }
/** * Gets the map on which the layer is rendered * * @return map on which the layer is rendered */ public GoogleMap getMap(){ return mRenderer.getMap(); }
/** * Changes the map that GeoJsonFeature objects are being drawn onto. Existing objects are * removed from the previous map and drawn onto the new map. * * @param map GoogleMap to place GeoJsonFeature objects on */ public void setMap(GoogleMap map) { super.setMap(map); for (Feature feature : super.getFeatures()) { redrawFeatureToMap((GeoJsonFeature) feature, map); } }
MarkerOptions markerOptions = style.getMarkerOptions(); if (inlineStyle != null) { setInlinePointStyle(markerOptions, inlineStyle, style.getIconUrl()); } else if (style.getIconUrl() != null) { addMarkerIcons(style.getIconUrl(), markerOptions); Marker marker = addPointToMap(markerOptions, (KmlPoint) geometry); marker.setVisible(isVisible); setMarkerInfoWindow(style, marker, placemark); if (hasDrawOrder) { marker.setZIndex(drawOrder); PolylineOptions polylineOptions = style.getPolylineOptions(); if (inlineStyle != null) { setInlineLineStringStyle(polylineOptions, inlineStyle); } else if (style.isLineRandomColorMode()) { polylineOptions.color(KmlStyle.computeRandomColor(polylineOptions.getColor())); Polyline polyline = addLineStringToMap(polylineOptions, (LineString) geometry); polyline.setVisible(isVisible); if (hasDrawOrder) { PolygonOptions polygonOptions = style.getPolygonOptions(); if (inlineStyle != null) { setInlinePolygonStyle(polygonOptions, inlineStyle); } else if (style.isPolyRandomColorMode()) { polygonOptions.fillColor(KmlStyle.computeRandomColor(polygonOptions.getFillColor()));
markerOptions = ((KmlPlacemark) feature).getMarkerOptions(); return addPointToMap(markerOptions, (GeoJsonPoint) geometry); case "LineString": PolylineOptions polylineOptions = null; polylineOptions = ((KmlPlacemark) feature).getPolylineOptions(); return addLineStringToMap(polylineOptions, (GeoJsonLineString) geometry); case "Polygon": PolygonOptions polygonOptions = null; polygonOptions = ((KmlPlacemark) feature).getPolygonOptions(); return addPolygonToMap(polygonOptions, (DataPolygon) geometry); case "MultiPoint": return addMultiPointToMap(((GeoJsonFeature) feature).getPointStyle(), (GeoJsonMultiPoint) geometry); case "MultiLineString": return addMultiLineStringToMap(((GeoJsonFeature) feature).getLineStringStyle(), ((GeoJsonMultiLineString) geometry)); case "MultiPolygon": return addMultiPolygonToMap(((GeoJsonFeature) feature).getPolygonStyle(), ((GeoJsonMultiPolygon) geometry)); case "GeometryCollection": return addGeometryCollectionToMap(((GeoJsonFeature) feature), ((GeoJsonGeometryCollection) geometry).getGeometries());
Object mapObject = FEATURE_NOT_ON_MAP; if (feature instanceof GeoJsonFeature) { setFeatureDefaultStyles((GeoJsonFeature) feature); removeFromMap(mFeatures.get(feature)); boolean isPlacemarkVisible = getPlacemarkVisibility(feature); String placemarkId = feature.getId(); Geometry geometry = feature.getGeometry(); KmlStyle style = getPlacemarkStyle(placemarkId); KmlStyle inlineStyle = ((KmlPlacemark) feature).getInlineStyle(); mapObject = addKmlPlacemarkToMap((KmlPlacemark) feature, geometry, style, inlineStyle, isPlacemarkVisible); } else { mapObject = addGeoJsonFeatureToMap(feature, feature.getGeometry());
public void testRemoveFeature() throws Exception { Point p = new Point(new LatLng(40, 50)); Feature feature1 = new Feature(p, null, null); mRenderer.addFeature(feature1); mRenderer.removeFeature(feature1); assertFalse(mRenderer.getFeatures().contains(feature1)); }
public void testAddFeature() throws Exception { Point p = new Point(new LatLng(30, 50)); Feature feature1 = new Feature(p, null, null); mRenderer.addFeature(feature1); assertTrue(mRenderer.getFeatures().contains(feature1)); }
/** * Removes all GeoJsonFeature objects stored in the mFeatures hashmap from the map */ public void removeLayerFromMap() { if (isLayerOnMap()) { for (Feature feature : super.getFeatures()) { removeFromMap(super.getAllFeatures().get(feature)); feature.deleteObserver(this); } setLayerVisibility(false); } }
/** * Gets an iterable of all Feature elements that have been added to the layer * * @return iterable of Feature elements */ public Iterable<? extends Feature> getFeatures(){ return mRenderer.getFeatures(); }
/** * Remove a specified feature from the map * * @param feature feature to be removed */ protected void removeFeature(Feature feature) { mRenderer.removeFeature(feature); }
/** * Adds all Geometry objects stored in the GeoJsonGeometryCollection onto the map. * Supports recursive GeometryCollections. * * @param feature contains relevant styling properties for the Geometry inside * the GeoJsonGeometryCollection * @param geoJsonGeometries contains an array of Geometry objects * @return array of Marker, Polyline, Polygons that have been added to the map */ private ArrayList<Object> addGeometryCollectionToMap(GeoJsonFeature feature, List<Geometry> geoJsonGeometries) { ArrayList<Object> geometries = new ArrayList<>(); for (Geometry geometry : geoJsonGeometries) { geometries.add(addGeoJsonFeatureToMap(feature, geometry)); } return geometries; }
/** * Adds all the geometries within a KML MultiGeometry to the map. Supports recursive * MultiGeometry. Combines styling of the placemark with the coordinates of each geometry. * * @param multiGeometry contains array of geometries for the MultiGeometry * @param urlStyle contains relevant styling properties for the MultiGeometry * @return array of Marker, Polyline and Polygon objects */ private ArrayList<Object> addMultiGeometryToMap(KmlPlacemark placemark, KmlMultiGeometry multiGeometry, KmlStyle urlStyle, KmlStyle inlineStyle, boolean isContainerVisible) { ArrayList<Object> mapObjects = new ArrayList<>(); ArrayList<Geometry> kmlObjects = multiGeometry.getGeometryObject(); for (Geometry kmlGeometry : kmlObjects) { mapObjects.add(addKmlPlacemarkToMap(placemark, kmlGeometry, urlStyle, inlineStyle, isContainerVisible)); } return mapObjects; }
/** * Adds all GeoJsonLineString objects in the GeoJsonMultiLineString to the map as multiple * Polylines * * @param lineStringStyle contains relevant styling properties for the Polylines * @param multiLineString contains an array of GeoJsonLineStrings * @return array of Polylines that have been added to the map */ private ArrayList<Polyline> addMultiLineStringToMap(GeoJsonLineStringStyle lineStringStyle, GeoJsonMultiLineString multiLineString) { ArrayList<Polyline> polylines = new ArrayList<>(); for (GeoJsonLineString geoJsonLineString : multiLineString.getLineStrings()) { polylines.add(addLineStringToMap(lineStringStyle.toPolylineOptions(), geoJsonLineString)); } return polylines; }
public void setUp() throws Exception { super.setUp(); HashMap<Feature, Object> features = new HashMap<>(); LineString lineString = new LineString(new ArrayList<>(Arrays.asList(new LatLng(0, 0), new LatLng(50, 50)))); Feature feature1 = new Feature(lineString, null, null); Point point = new Point(new LatLng(0, 0)); Feature feature2 = new Feature(point, null, null); features.put(feature1, null); features.put(feature2, null); featureSet = features.keySet(); mRenderer = new Renderer(mMap1, features); }
/** * Sets the inline point style by copying over the styles that have been set * * @param markerOptions marker options object to add inline styles to * @param inlineStyle inline styles to apply * @param markerUrlIconUrl default marker icon URL from shared style */ private void setInlinePointStyle(MarkerOptions markerOptions, KmlStyle inlineStyle, String markerUrlIconUrl) { MarkerOptions inlineMarkerOptions = inlineStyle.getMarkerOptions(); if (inlineStyle.isStyleSet("heading")) { markerOptions.rotation(inlineMarkerOptions.getRotation()); } if (inlineStyle.isStyleSet("hotSpot")) { markerOptions .anchor(inlineMarkerOptions.getAnchorU(), inlineMarkerOptions.getAnchorV()); } if (inlineStyle.isStyleSet("markerColor")) { markerOptions.icon(inlineMarkerOptions.getIcon()); } if (inlineStyle.isStyleSet("iconUrl")) { addMarkerIcons(inlineStyle.getIconUrl(), markerOptions); } else if (markerUrlIconUrl != null) { // Inline style with no icon defined addMarkerIcons(markerUrlIconUrl, markerOptions); } }
/** * Adds all of the stored features in the layer onto the map if the layer is * not already on the map. */ public void addLayerToMap() { if (!isLayerOnMap()) { setLayerVisibility(true); for (Feature feature : super.getFeatures()) { addFeature((GeoJsonFeature) feature); } } }
public void testGetFeatures() throws Exception { assertEquals(featureSet, mRenderer.getFeatures()); }
public void testGetMap() throws Exception { assertEquals(mMap1, mRenderer.getMap()); }