/** * Gets the style id associated with the basic_placemark * * @return style id */ public String getStyleId() { return super.getId(); }
/** * Gets the visibility of the placemark if it is specified. A visibility value of "1" * corresponds as "true", a visibility value of "0" corresponds as false. If the * visibility is not set, the method returns "true". * * @param feature Feature to obtain visibility from. * @return False if a Feature has a visibility value of "1", true otherwise. */ protected static boolean getPlacemarkVisibility(Feature feature) { boolean isFeatureVisible = true; if (feature.hasProperty("visibility")) { String placemarkVisibility = feature.getProperty("visibility"); if (Integer.parseInt(placemarkVisibility) == 0) { isFeatureVisible = false; } } return isFeatureVisible; }
/** * Removes a given property * * @param property key of the property to remove * @return value of the removed property or null if there was no corresponding key */ public String removeProperty(String property) { return super.removeProperty(property); }
public void testProperty() throws Exception { HashMap<String, String> properties = new HashMap<>(); properties.put("Color", "Red"); properties.put("Width", "3"); feature = new Feature(null, null, properties); assertFalse(feature.hasProperty("llama")); assertTrue(feature.hasProperty("Color")); assertEquals("Red", feature.getProperty("Color")); assertTrue(feature.hasProperty("Width")); assertEquals("3", feature.getProperty("Width")); assertNull(feature.removeProperty("banana")); assertEquals("3", feature.removeProperty("Width")); assertNull(feature.setProperty("Width", "10")); assertEquals("10", feature.setProperty("Width", "500")); }
/** * Goes through the every placemark, style and properties object within a <Folder> tag * * @param kmlContainer Folder to obtain placemark and styles from */ private void addContainerObjectToMap(KmlContainer kmlContainer, boolean isContainerVisible) { for (Feature placemark : kmlContainer.getPlacemarks()) { boolean isPlacemarkVisible = getPlacemarkVisibility(placemark); boolean isObjectVisible = isContainerVisible && isPlacemarkVisible; if (placemark.getGeometry() != null) { String placemarkId = placemark.getId(); Geometry geometry = placemark.getGeometry(); KmlStyle style = getPlacemarkStyle(placemarkId); KmlStyle inlineStyle = ((KmlPlacemark) placemark).getInlineStyle(); Object mapObject = addKmlPlacemarkToMap((KmlPlacemark) placemark, geometry, style, inlineStyle, isObjectVisible); kmlContainer.setPlacemark((KmlPlacemark) placemark, mapObject); putContainerFeature(mapObject, placemark); } } }
if (feature.hasGeometry()) { 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());
@Override public void onFeatureClick(Feature feature) { Toast.makeText(GeoJsonDemoActivity.this, "Feature clicked: " + feature.getProperty("title"), Toast.LENGTH_SHORT).show(); }
public void testGeometry() { feature = new Feature(null, null, null); assertNull(feature.getGeometry()); Point point = new Point(new LatLng(0, 0)); feature.setGeometry(point); assertEquals(point, feature.getGeometry()); feature.setGeometry(null); assertNull(feature.getGeometry()); LineString lineString = new LineString(new ArrayList<>(Arrays.asList(new LatLng(0, 0), new LatLng(50, 50)))); feature = new Feature(lineString, null, null); assertEquals(lineString, feature.getGeometry()); feature.setGeometry(point); assertEquals(point, feature.getGeometry()); feature.setGeometry(null); assertNull(feature.getGeometry()); feature.setGeometry(lineString); assertEquals(lineString, feature.getGeometry()); }
/** * Store a new property key and value * * @param property key of the property to store * @param propertyValue value of the property to store * @return previous value with the same key, otherwise null if the key didn't exist */ public String setProperty(String property, String propertyValue) { return super.setProperty(property, propertyValue); }
/** * Sets the stored Geometry and redraws it on the layer if it has already been added * * @param geometry Geometry to set */ public void setGeometry(Geometry geometry) { super.setGeometry(geometry); setChanged(); notifyObservers(); }
/** * Adds the marker icon stored in mMarkerIconCache, to the {@link com.google.android.gms.maps.model.Marker} * * @param iconUrl icon url of icon to add to markers * @param placemarks */ private void addIconToMarkers(String iconUrl, HashMap<KmlPlacemark, Object> placemarks) { for (Feature placemark : placemarks.keySet()) { KmlStyle urlStyle = getStylesRenderer().get(placemark.getId()); KmlStyle inlineStyle = ((KmlPlacemark) placemark).getInlineStyle(); if ("Point".equals(placemark.getGeometry().getGeometryType())) { boolean isInlineStyleIcon = inlineStyle != null && iconUrl .equals(inlineStyle.getIconUrl()); boolean isPlacemarkStyleIcon = urlStyle != null && iconUrl .equals(urlStyle.getIconUrl()); if (isInlineStyleIcon) { scaleBitmap(inlineStyle, placemarks, (KmlPlacemark) placemark); } else if (isPlacemarkStyleIcon) { scaleBitmap(urlStyle, placemarks, (KmlPlacemark) placemark); } } } }
@Override public void onFeatureClick(Feature feature) { Toast.makeText(DataLoaderActivity.this, "Feature clicked: " + feature.getProperty("title"), Toast.LENGTH_SHORT).show(); }
@Override public void onFeatureClick(Feature feature) { Toast.makeText(KmlDemoActivity.this, "Feature clicked: " + feature.getId(), Toast.LENGTH_SHORT).show(); } });
@Override public void onFeatureClick(Feature feature) { Toast.makeText(context, "Feature clicked: " + feature.getId(), Toast.LENGTH_SHORT).show(); }
@Override public void onFeatureClick(Feature feature) { Toast.makeText(DataLoaderActivity.this, "Feature clicked: " + feature.getId(), Toast.LENGTH_SHORT).show(); }