当前位置: 首页>>代码示例>>Java>>正文


Java GeoJsonFeature类代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:googlemaps,项目名称:android-maps-utils,代码行数:29,代码来源:GeoJsonDemoActivity.java

示例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);
        }
    }
}
 
开发者ID:bkhezry,项目名称:ExtraMapUtils,代码行数:25,代码来源:AppUtils.java

示例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);
    }
}
 
开发者ID:googlemaps,项目名称:android-maps-utils,代码行数:17,代码来源:Renderer.java

示例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);
}
 
开发者ID:googlemaps,项目名称:android-maps-utils,代码行数:32,代码来源:Renderer.java

示例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;
}
 
开发者ID:googlemaps,项目名称:android-maps-utils,代码行数:50,代码来源:Renderer.java

示例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;
}
 
开发者ID:googlemaps,项目名称:android-maps-utils,代码行数:18,代码来源:Renderer.java


注:本文中的com.google.maps.android.data.geojson.GeoJsonFeature类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。