Search in sources :

Example 1 with GeoJsonFeature

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

the class MapFragment method onMarkerClick.

@Override
public boolean onMarkerClick(Marker marker) {
    final String title = marker.getTitle();
    final GeoJsonFeature feature = mMarkers.get(title);
    // Log clicks on all markers (regardless of type)
    // ANALYTICS EVENT: Click on marker on the map.
    // Contains: Marker ID (for example room UUID)
    AnalyticsHelper.sendEvent("Map", "markerclick", title);
    deselectActiveMarker();
    selectMarker(feature);
    return true;
}
Also used : GeoJsonFeature(com.google.maps.android.geojson.GeoJsonFeature)

Example 2 with GeoJsonFeature

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

the class MapFragment method onMarkersLoaded.

private void onMarkersLoaded(JSONObject data) {
    if (data != null) {
        // Parse the JSONObject as GeoJson and add it to the map
        mGeoJsonLayer = MapUtils.processGeoJson(getContext(), mMap, data);
        if (mGeoJsonLayer == null) {
            return;
        }
        mGeoJsonLayer.addLayerToMap();
        for (GeoJsonFeature feature : mGeoJsonLayer.getFeatures()) {
            if (feature == null) {
                break;
            }
            mMarkers.put(feature.getProperty("id"), feature);
        }
    }
    // Highlight a room if there is a pending id.
    highlightRoom(mHighlightedRoomId);
    mHighlightedRoomId = null;
}
Also used : GeoJsonFeature(com.google.maps.android.geojson.GeoJsonFeature)

Example 3 with GeoJsonFeature

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

the class MapFragment method highlightRoom.

private boolean highlightRoom(String roomId) {
    if (roomId == null) {
        return false;
    }
    // Hide the active marker.
    deselectActiveMarker();
    GeoJsonFeature highlightedFeature = mMarkers.get(roomId);
    if (highlightedFeature == null) {
        // Room not found. Deselect active marker and hide the info details anyway.
        mCallbacks.onInfoHide();
        return false;
    }
    selectMarker(highlightedFeature);
    GeoJsonPoint room = (GeoJsonPoint) highlightedFeature.getGeometry();
    centerMap(room.getCoordinates());
    return true;
}
Also used : GeoJsonFeature(com.google.maps.android.geojson.GeoJsonFeature) GeoJsonPoint(com.google.maps.android.geojson.GeoJsonPoint)

Example 4 with GeoJsonFeature

use of com.google.maps.android.geojson.GeoJsonFeature 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 GeoJsonFeature

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

the class EditorMapFragment method setElementsDraggable.

/**
 * Sets all markers on the map as draggable.
 */
public void setElementsDraggable(boolean isDraggable) {
    // Set all markers as draggable
    for (GeoJsonFeature feature : mMarkers.values()) {
        GeoJsonPointStyle pointStyle = feature.getPointStyle();
        pointStyle.setDraggable(isDraggable);
        feature.setPointStyle(pointStyle);
    }
}
Also used : GeoJsonFeature(com.google.maps.android.geojson.GeoJsonFeature) GeoJsonPointStyle(com.google.maps.android.geojson.GeoJsonPointStyle)

Aggregations

GeoJsonFeature (com.google.maps.android.geojson.GeoJsonFeature)5 GeoJsonPointStyle (com.google.maps.android.geojson.GeoJsonPointStyle)2 GeoJsonLayer (com.google.maps.android.geojson.GeoJsonLayer)1 GeoJsonPoint (com.google.maps.android.geojson.GeoJsonPoint)1 IconGenerator (com.google.maps.android.ui.IconGenerator)1