本文整理汇总了Java中com.google.maps.android.data.geojson.GeoJsonFeature类的典型用法代码示例。如果您正苦于以下问题:Java GeoJsonFeature类的具体用法?Java GeoJsonFeature怎么用?Java GeoJsonFeature使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GeoJsonFeature类属于com.google.maps.android.data.geojson包,在下文中一共展示了GeoJsonFeature类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addColorsToMarkers
import com.google.maps.android.data.geojson.GeoJsonFeature; //导入依赖的package包/类
/**
* Adds a point style to all features to change the color of the marker based on its magnitude
* property
*/
private void addColorsToMarkers(GeoJsonLayer layer) {
// Iterate over all the features stored in the layer
for (GeoJsonFeature feature : layer.getFeatures()) {
// Check if the magnitude property exists
if (feature.getProperty("mag") != null && feature.hasProperty("place")) {
double magnitude = Double.parseDouble(feature.getProperty("mag"));
// Get the icon for the feature
BitmapDescriptor pointIcon = BitmapDescriptorFactory
.defaultMarker(magnitudeToColor(magnitude));
// Create a new point style
GeoJsonPointStyle pointStyle = new GeoJsonPointStyle();
// Set options for the point style
pointStyle.setIcon(pointIcon);
pointStyle.setTitle("Magnitude of " + magnitude);
pointStyle.setSnippet("Earthquake occured " + feature.getProperty("place"));
// Assign the point style to the feature
feature.setPointStyle(pointStyle);
}
}
}
示例2: addColorsToMarkers
import com.google.maps.android.data.geojson.GeoJsonFeature; //导入依赖的package包/类
public static void addColorsToMarkers(GeoJsonLayer layer) {
// Iterate over all the features stored in the layer
for (GeoJsonFeature feature : layer.getFeatures()) {
// Check if the magnitude property exists
if (feature.getProperty("mag") != null && feature.hasProperty("place")) {
double magnitude = Double.parseDouble(feature.getProperty("mag"));
// Get the icon for the feature
BitmapDescriptor pointIcon = BitmapDescriptorFactory
.defaultMarker(magnitudeToColor(magnitude));
// Create a new point style
GeoJsonPointStyle pointStyle = new GeoJsonPointStyle();
// Set options for the point style
pointStyle.setIcon(pointIcon);
pointStyle.setTitle("Magnitude of " + magnitude);
pointStyle.setSnippet("Earthquake occured " + feature.getProperty("place"));
// Assign the point style to the feature
feature.setPointStyle(pointStyle);
}
}
}
示例3: setFeatureDefaultStyles
import com.google.maps.android.data.geojson.GeoJsonFeature; //导入依赖的package包/类
/**
* Checks for each style in the feature and adds a default style if none is applied
*
* @param feature feature to apply default styles to
*/
private void setFeatureDefaultStyles(GeoJsonFeature feature) {
if (feature.getPointStyle() == null) {
feature.setPointStyle(mDefaultPointStyle);
}
if (feature.getLineStringStyle() == null) {
feature.setLineStringStyle(mDefaultLineStringStyle);
}
if (feature.getPolygonStyle() == null) {
feature.setPolygonStyle(mDefaultPolygonStyle);
}
}
示例4: addFeature
import com.google.maps.android.data.geojson.GeoJsonFeature; //导入依赖的package包/类
/**
* Adds a new Feature to the map if its geometry property is not null.
*
* @param feature feature to add to the map
*/
public void addFeature(Feature feature) {
Object mapObject = FEATURE_NOT_ON_MAP;
if (feature instanceof GeoJsonFeature) {
setFeatureDefaultStyles((GeoJsonFeature) feature);
}
if (mLayerOnMap) {
if (mFeatures.containsKey(feature)) {
// Remove current map objects before adding new ones
removeFromMap(mFeatures.get(feature));
}
if (feature.hasGeometry()) {
// Create new map object
if (feature instanceof KmlPlacemark) {
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());
}
}
}
mFeatures.put(feature, mapObject);
}
示例5: addGeoJsonFeatureToMap
import com.google.maps.android.data.geojson.GeoJsonFeature; //导入依赖的package包/类
/**
* Adds a new object onto the map using the Geometry for the coordinates and the
* Feature for the styles. (used for GeoJson)
*
* @param feature feature to get geometry style
* @param geometry geometry to add to the map
*/
protected Object addGeoJsonFeatureToMap(Feature feature, Geometry geometry) {
String geometryType = geometry.getGeometryType();
switch (geometryType) {
case "Point":
MarkerOptions markerOptions = null;
if (feature instanceof GeoJsonFeature) {
markerOptions = ((GeoJsonFeature) feature).getMarkerOptions();
} else if (feature instanceof KmlPlacemark) {
markerOptions = ((KmlPlacemark) feature).getMarkerOptions();
}
return addPointToMap(markerOptions, (GeoJsonPoint) geometry);
case "LineString":
PolylineOptions polylineOptions = null;
if (feature instanceof GeoJsonFeature) {
polylineOptions = ((GeoJsonFeature) feature).getPolylineOptions();
} else if (feature instanceof KmlPlacemark) {
polylineOptions = ((KmlPlacemark) feature).getPolylineOptions();
}
return addLineStringToMap(polylineOptions, (GeoJsonLineString) geometry);
case "Polygon":
PolygonOptions polygonOptions = null;
if (feature instanceof GeoJsonFeature) {
polygonOptions = ((GeoJsonFeature) feature).getPolygonOptions();
} else if (feature instanceof KmlPlacemark) {
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());
}
return null;
}
示例6: addGeometryCollectionToMap
import com.google.maps.android.data.geojson.GeoJsonFeature; //导入依赖的package包/类
/**
* 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;
}