Java Code Examples for com.google.android.gms.maps.model.Marker#setZIndex()

The following examples show how to use com.google.android.gms.maps.model.Marker#setZIndex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PolygonHoleMarkers.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setZIndex(float zIndex) {
    for (Marker marker : markers) {
        marker.setZIndex(zIndex);
    }
}
 
Example 2
Source File: PolygonMarkers.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setZIndex(float zIndex) {
    if (polygon != null) {
        polygon.setZIndex(zIndex);
    }
    for (Marker marker : markers) {
        marker.setZIndex(zIndex);
    }
    for (PolygonHoleMarkers hole : holes) {
        hole.setZIndex(zIndex);
    }
}
 
Example 3
Source File: PolylineMarkers.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setZIndex(float zIndex) {
    if (polyline != null) {
        polyline.setZIndex(zIndex);
    }
    for (Marker marker : markers) {
        marker.setZIndex(zIndex);
    }
}
 
Example 4
Source File: MultiMarker.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setZIndex(float zIndex) {
    for (Marker marker : markers) {
        marker.setZIndex(zIndex);
    }
}
 
Example 5
Source File: MarkerDemoActivity.java    From android-samples with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onMarkerClick(final Marker marker) {
    if (marker.equals(mPerth)) {
        // This causes the marker at Perth to bounce into position when it is clicked.
        final Handler handler = new Handler();
        final long start = SystemClock.uptimeMillis();
        final long duration = 1500;

        final Interpolator interpolator = new BounceInterpolator();

        handler.post(new Runnable() {
            @Override
            public void run() {
                long elapsed = SystemClock.uptimeMillis() - start;
                float t = Math.max(
                        1 - interpolator.getInterpolation((float) elapsed / duration), 0);
                marker.setAnchor(0.5f, 1.0f + 2 * t);

                if (t > 0.0) {
                    // Post again 16ms later.
                    handler.postDelayed(this, 16);
                }
            }
        });
    } else if (marker.equals(mAdelaide)) {
        // This causes the marker at Adelaide to change color and alpha.
        marker.setIcon(BitmapDescriptorFactory.defaultMarker(mRandom.nextFloat() * 360));
        marker.setAlpha(mRandom.nextFloat());
    }

    // Markers have a z-index that is settable and gettable.
    float zIndex = marker.getZIndex() + 1.0f;
    marker.setZIndex(zIndex);
    Toast.makeText(this, marker.getTitle() + " z-index set to " + zIndex,
            Toast.LENGTH_SHORT).show();

    mLastSelectedMarker = marker;
    // We return false to indicate that we have not consumed the event and that we wish
    // for the default behavior to occur (which is for the camera to move such that the
    // marker is centered and for the marker's info window to open, if it has one).
    return false;
}
 
Example 6
Source File: Renderer.java    From android-maps-utils with Apache License 2.0 4 votes vote down vote up
/**
 * Adds a single geometry object to the map with its specified style (used for KML)
 *
 * @param geometry defines the type of object to add to the map
 * @param style    defines styling properties to add to the object when added to the map
 * @return the object that was added to the map, this is a Marker, Polyline, Polygon or an array
 * of either objects
 */
protected Object addKmlPlacemarkToMap(KmlPlacemark placemark, Geometry geometry, KmlStyle style,
                                      KmlStyle inlineStyle, boolean isVisible) {
    String geometryType = geometry.getGeometryType();
    boolean hasDrawOrder = placemark.hasProperty("drawOrder");
    float drawOrder = 0;

    if (hasDrawOrder) {
        try {
            drawOrder = Float.parseFloat(placemark.getProperty("drawOrder"));
        } catch (NumberFormatException e) {
            hasDrawOrder = false;
        }
    }
    switch (geometryType) {
        case "Point":
            MarkerOptions markerOptions = style.getMarkerOptions();
            if (inlineStyle != null) {
                setInlinePointStyle(markerOptions, inlineStyle, style);
            } else if (style.getIconUrl() != null) {
                // Use shared style
                addMarkerIcons(style.getIconUrl(), style.getIconScale(), markerOptions);
            }
            Marker marker = addPointToMap(markerOptions, (KmlPoint) geometry);
            marker.setVisible(isVisible);
            setMarkerInfoWindow(style, marker, placemark);
            if (hasDrawOrder) {
                marker.setZIndex(drawOrder);
            }
            return marker;
        case "LineString":
            PolylineOptions polylineOptions = style.getPolylineOptions();
            if (inlineStyle != null) {
                setInlineLineStringStyle(polylineOptions, inlineStyle);
            } else if (style.isLineRandomColorMode()) {
                polylineOptions.color(KmlStyle.computeRandomColor(polylineOptions.getColor()));
            }
            Polyline polyline = addLineStringToMap(polylineOptions, (LineString) geometry);
            polyline.setVisible(isVisible);
            if (hasDrawOrder) {
                polyline.setZIndex(drawOrder);
            }
            return polyline;
        case "Polygon":
            PolygonOptions polygonOptions = style.getPolygonOptions();
            if (inlineStyle != null) {
                setInlinePolygonStyle(polygonOptions, inlineStyle);
            } else if (style.isPolyRandomColorMode()) {
                polygonOptions.fillColor(KmlStyle.computeRandomColor(polygonOptions.getFillColor()));
            }
            Polygon polygon = addPolygonToMap(polygonOptions, (DataPolygon) geometry);
            polygon.setVisible(isVisible);
            if (hasDrawOrder) {
                polygon.setZIndex(drawOrder);
            }
            return polygon;
        case "MultiGeometry":
            return addMultiGeometryToMap(placemark, (KmlMultiGeometry) geometry, style, inlineStyle,
                    isVisible);
    }
    return null;
}