Search in sources :

Example 1 with GeoJsonPointStyle

use of com.google.maps.android.geojson.GeoJsonPointStyle in project iosched by google.

the class MapFragment method selectActiveMarker.

private void selectActiveMarker(GeoJsonFeature feature) {
    if (mActiveMarker == feature || feature == null) {
        return;
    }
    final String typeString = feature.getProperty("type");
    final int type = MapUtils.detectMarkerType(typeString);
    mActiveMarker = feature;
    GeoJsonPointStyle style = mActiveMarker.getPointStyle();
    if (type == MarkerModel.TYPE_ICON) {
        // For TYPE_ICON markers, use the MapUtils to generate a tinted icon.
        final Bitmap iconBitmap = MapUtils.getIconMarkerBitmap(getContext(), typeString, true);
        if (iconBitmap != null) {
            style.setIcon(BitmapDescriptorFactory.fromBitmap(iconBitmap));
        }
    } else if (MapUtils.useActiveMarker(type)) {
        // Replace the icon of this feature with the generic active marker.
        style.setIcon(ICON_ACTIVE);
    }
    mActiveMarker.setPointStyle(style);
}
Also used : Bitmap(android.graphics.Bitmap) GeoJsonPointStyle(com.google.maps.android.geojson.GeoJsonPointStyle) GeoJsonPoint(com.google.maps.android.geojson.GeoJsonPoint)

Example 2 with GeoJsonPointStyle

use of com.google.maps.android.geojson.GeoJsonPointStyle in project iosched by google.

the class MapFragment method deselectActiveMarker.

private void deselectActiveMarker() {
    if (mActiveMarker == null) {
        return;
    }
    final String typeString = mActiveMarker.getProperty("type");
    final int type = MapUtils.detectMarkerType(typeString);
    GeoJsonPointStyle style = mActiveMarker.getPointStyle();
    if (type == MarkerModel.TYPE_ICON) {
        // For icon markers, use the Maputils to load the original icon again.
        final Bitmap iconBitmap = MapUtils.getIconMarkerBitmap(getContext(), typeString, false);
        if (iconBitmap != null) {
            style.setIcon(BitmapDescriptorFactory.fromBitmap(iconBitmap));
        }
    } else if (MapUtils.useActiveMarker(type)) {
        // Change the icon back if the generic active marker was used.
        style.setIcon(ICON_NORMAL);
    }
    mActiveMarker.setPointStyle(style);
    mActiveMarker = null;
}
Also used : Bitmap(android.graphics.Bitmap) GeoJsonPointStyle(com.google.maps.android.geojson.GeoJsonPointStyle) GeoJsonPoint(com.google.maps.android.geojson.GeoJsonPoint)

Example 3 with GeoJsonPointStyle

use of com.google.maps.android.geojson.GeoJsonPointStyle in project iosched by google.

the class MapUtils method createLabelMarker.

/**
 * Creates a GeoJsonPointStyle for a label.
 *
 * @param iconFactory Reusable IconFactory
 * @param title          Id to be embedded as the title
 * @param label       Text to be shown on the label
 */
private static GeoJsonPointStyle createLabelMarker(IconGenerator iconFactory, String title, String label) {
    final BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(iconFactory.makeIcon(label));
    GeoJsonPointStyle pointStyle = new GeoJsonPointStyle();
    pointStyle.setAnchor(0.5f, 0.5f);
    pointStyle.setTitle(title);
    pointStyle.setIcon(icon);
    pointStyle.setVisible(false);
    return pointStyle;
}
Also used : GeoJsonPointStyle(com.google.maps.android.geojson.GeoJsonPointStyle) BitmapDescriptor(com.google.android.gms.maps.model.BitmapDescriptor)

Example 4 with GeoJsonPointStyle

use of com.google.maps.android.geojson.GeoJsonPointStyle in project iosched by google.

the class MapUtils method processGeoJson.

public static GeoJsonLayer processGeoJson(Context context, GoogleMap mMap, JSONObject j) {
    GeoJsonLayer layer = new GeoJsonLayer(mMap, j);
    Iterator<GeoJsonFeature> iterator = layer.getFeatures().iterator();
    final IconGenerator labelIconGenerator = MapUtils.getLabelIconGenerator(context);
    while (iterator.hasNext()) {
        GeoJsonFeature feature = iterator.next();
        // get data
        final String id = feature.getProperty("id");
        final String typeString = feature.getProperty("type");
        final int type = MapUtils.detectMarkerType(typeString);
        final String label = feature.getProperty("title");
        GeoJsonPointStyle pointStyle = new GeoJsonPointStyle();
        if (type == MarkerModel.TYPE_LABEL) {
            // Label markers contain the label as its icon
            pointStyle = MapUtils.createLabelMarker(labelIconGenerator, id, label);
        } else if (type == MarkerModel.TYPE_ICON) {
            // An icon marker is mapped to a drawable based on its full type name
            pointStyle = MapUtils.createIconMarker(typeString, id, false, context);
        } else if (type != MarkerModel.TYPE_INACTIVE) {
            // All other markers (that are not inactive) contain a pin icon
            pointStyle = MapUtils.createPinMarker(context, id);
        }
        // If the marker is invalid (e.g. the icon does not exist), remove it from the map.
        if (pointStyle == null) {
            iterator.remove();
        } else {
            pointStyle.setVisible(true);
            feature.setPointStyle(pointStyle);
        }
    }
    return layer;
}
Also used : GeoJsonFeature(com.google.maps.android.geojson.GeoJsonFeature) GeoJsonLayer(com.google.maps.android.geojson.GeoJsonLayer) GeoJsonPointStyle(com.google.maps.android.geojson.GeoJsonPointStyle) IconGenerator(com.google.maps.android.ui.IconGenerator)

Example 5 with GeoJsonPointStyle

use of com.google.maps.android.geojson.GeoJsonPointStyle in project iosched by google.

the class MapUtils method createPinMarker.

/**
 * Creates a GeoJsonPointStyle for a session.
 *
 * @param title Id to be embedded as the title
 */
public static GeoJsonPointStyle createPinMarker(@NonNull Context context, String title) {
    final BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(UIUtils.drawableToBitmap(context, R.drawable.map_marker_unselected));
    GeoJsonPointStyle pointStyle = new GeoJsonPointStyle();
    pointStyle.setTitle(title);
    pointStyle.setIcon(icon);
    pointStyle.setVisible(false);
    pointStyle.setAnchor(0.5f, 0.85526f);
    return pointStyle;
}
Also used : GeoJsonPointStyle(com.google.maps.android.geojson.GeoJsonPointStyle) BitmapDescriptor(com.google.android.gms.maps.model.BitmapDescriptor)

Aggregations

GeoJsonPointStyle (com.google.maps.android.geojson.GeoJsonPointStyle)7 Bitmap (android.graphics.Bitmap)3 BitmapDescriptor (com.google.android.gms.maps.model.BitmapDescriptor)3 GeoJsonFeature (com.google.maps.android.geojson.GeoJsonFeature)2 GeoJsonPoint (com.google.maps.android.geojson.GeoJsonPoint)2 GeoJsonLayer (com.google.maps.android.geojson.GeoJsonLayer)1 IconGenerator (com.google.maps.android.ui.IconGenerator)1