Java Code Examples for com.google.android.gms.maps.model.Polyline#setVisible()

The following examples show how to use com.google.android.gms.maps.model.Polyline#setVisible() . 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: 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;
}
 
Example 2
Source File: PolylineManager.java    From android-maps-utils with Apache License 2.0 4 votes vote down vote up
public void showAll() {
    for (Polyline polyline : getPolylines()) {
        polyline.setVisible(true);
    }
}
 
Example 3
Source File: PolylineManager.java    From android-maps-utils with Apache License 2.0 4 votes vote down vote up
public void hideAll() {
    for (Polyline polyline : getPolylines()) {
        polyline.setVisible(false);
    }
}
 
Example 4
Source File: MultiPolyline.java    From geopackage-android-map with MIT License 2 votes vote down vote up
/**
 * Set visibility on the map
 *
 * @param visible visibility flag
 * @since 1.3.2
 */
public void setVisible(boolean visible) {
    for (Polyline polyline : polylines) {
        polyline.setVisible(visible);
    }
}