Java Code Examples for com.google.android.gms.maps.model.PolygonOptions

The following examples show how to use com.google.android.gms.maps.model.PolygonOptions. These examples are extracted from open source projects. 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
private void addPolygon()
{
	googleMap.clear();
	PolygonOptions polygonOptions = new PolygonOptions();
	polygonOptions.add(new LatLng(0, 0));
	polygonOptions.add(new LatLng(-3, 2.5));
	polygonOptions.add(new LatLng(0, 5));
	polygonOptions.add(new LatLng(3, 5));
	polygonOptions.add(new LatLng(3, 0));
	polygonOptions.add(new LatLng(0, 0));
	polygonOptions.clickable(true);
	polygonOptions.fillColor(Color.BLUE);

	googleMap.addPolygon(polygonOptions).setTag(new CustomTag("polygon"));
	googleMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(0, 0)));
}
 
Example 2
Source Project: geopackage-android-map   Source File: StyleUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Set the style into the polygon options
 *
 * @param polygonOptions polygon options
 * @param style          style row
 * @param density        display density: {@link android.util.DisplayMetrics#density}
 * @return true if style was set into the polygon options
 */
public static boolean setStyle(PolygonOptions polygonOptions, StyleRow style, float density) {

    if (style != null) {

        Color color = style.getColorOrDefault();
        polygonOptions.strokeColor(color.getColorWithAlpha());

        double width = style.getWidthOrDefault();
        polygonOptions.strokeWidth((float) width * density);

        Color fillColor = style.getFillColor();
        if (fillColor != null) {
            polygonOptions.fillColor(fillColor.getColorWithAlpha());
        }
    }

    return style != null;
}
 
Example 3
Source Project: geopackage-android-map   Source File: MapUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Is the point of the polygon
 *
 * @param point     point
 * @param polygon   polygon
 * @param geodesic  geodesic check flag
 * @param tolerance distance tolerance
 * @return true if on the polygon
 */
public static boolean isPointOnPolygon(LatLng point, PolygonOptions polygon, boolean geodesic, double tolerance) {

    boolean onPolygon = PolyUtil.containsLocation(point, polygon.getPoints(), geodesic) ||
            PolyUtil.isLocationOnEdge(point, polygon.getPoints(), geodesic, tolerance);

    if (onPolygon) {
        for (List<LatLng> hole : polygon.getHoles()) {
            if (PolyUtil.containsLocation(point, hole, geodesic)) {
                onPolygon = false;
                break;
            }
        }
    }

    return onPolygon;
}
 
Example 4
Source Project: geopackage-android-map   Source File: GoogleMapShapeConverter.java    License: MIT License 6 votes vote down vote up
/**
 * Add a MultiPolygonOptions to the map as markers
 *
 * @param shapeMarkers             google map shape markers
 * @param map                      google map
 * @param multiPolygon             multi polygon options
 * @param polygonMarkerOptions     polygon marker options
 * @param polygonMarkerHoleOptions polygon marker hole options
 * @param globalPolygonOptions     global polygon options
 * @return multi polygon markers
 */
public MultiPolygonMarkers addMultiPolygonToMapAsMarkers(
        GoogleMapShapeMarkers shapeMarkers, GoogleMap map,
        MultiPolygonOptions multiPolygon,
        MarkerOptions polygonMarkerOptions,
        MarkerOptions polygonMarkerHoleOptions,
        PolygonOptions globalPolygonOptions) {
    MultiPolygonMarkers multiPolygonMarkers = new MultiPolygonMarkers();
    for (PolygonOptions polygon : multiPolygon.getPolygonOptions()) {
        PolygonMarkers polygonMarker = addPolygonToMapAsMarkers(
                shapeMarkers, map, polygon, polygonMarkerOptions,
                polygonMarkerHoleOptions, globalPolygonOptions);
        shapeMarkers.add(polygonMarker);
        multiPolygonMarkers.add(polygonMarker);
    }
    return multiPolygonMarkers;
}
 
Example 5
/**
 * Compare Polygon with Map Polygon
 *
    * @param converter
 * @param polygon
 * @param polygon2
 */
private static void comparePolygonAndMapPolygon(GoogleMapShapeConverter converter,
           Polygon polygon,
		PolygonOptions polygon2) {
	List<LineString> rings = polygon.getRings();
	List<LatLng> points = polygon2.getPoints();
	List<List<LatLng>> holes = polygon2.getHoles();

	TestCase.assertEquals(polygon.numRings(), 1 + holes.size());

	LineString polygonRing = rings.get(0);
	compareLineStringAndLatLngs(converter, polygonRing, points);

	for (int i = 1; i < rings.size(); i++) {
		LineString ring = rings.get(i);
		List<LatLng> hole = holes.get(i - 1);
		compareLineStringAndLatLngs(converter, ring, hole);
	}
}
 
Example 6
Source Project: open-location-code   Source File: MyMapView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void drawCodeArea(final OpenLocationCode code) {
    if (code.equals(mLastDisplayedCode)) {
        // Skip if we're already displaying this location.
        return;
    }
    mLastDisplayedCode = code;
    if (mMap != null) {
        CodeArea area = code.decode();
        LatLng southWest = new LatLng(area.getSouthLatitude(), area.getWestLongitude());
        LatLng northWest = new LatLng(area.getNorthLatitude(), area.getWestLongitude());
        LatLng southEast = new LatLng(area.getSouthLatitude(), area.getEastLongitude());
        LatLng northEast = new LatLng(area.getNorthLatitude(), area.getEastLongitude());

        if (mCodePolygon != null) {
            mCodePolygon.remove();
        }

        mCodePolygon = mMap.addPolygon(
                new PolygonOptions().add(southWest, northWest,northEast, southEast)
                .strokeColor(ContextCompat.getColor(this.getContext(), R.color.code_box_stroke))
                .strokeWidth(CODE_AREA_STROKE_WIDTH)
                .fillColor(ContextCompat.getColor(this.getContext(), R.color.code_box_fill)));
    }
}
 
Example 7
Source Project: android-maps-utils   Source File: Renderer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sets the inline polygon style by copying over the styles that have been set
 *
 * @param polygonOptions polygon options object to add inline styles to
 * @param inlineStyle    inline styles to apply
 */
private void setInlinePolygonStyle(PolygonOptions polygonOptions, KmlStyle inlineStyle) {
    PolygonOptions inlinePolygonOptions = inlineStyle.getPolygonOptions();
    if (inlineStyle.hasFill() && inlineStyle.isStyleSet("fillColor")) {
        polygonOptions.fillColor(inlinePolygonOptions.getFillColor());
    }
    if (inlineStyle.hasOutline()) {
        if (inlineStyle.isStyleSet("outlineColor")) {
            polygonOptions.strokeColor(inlinePolygonOptions.getStrokeColor());
        }
        if (inlineStyle.isStyleSet("width")) {
            polygonOptions.strokeWidth(inlinePolygonOptions.getStrokeWidth());
        }
    }
    if (inlineStyle.isPolyRandomColorMode()) {
        polygonOptions.fillColor(KmlStyle.computeRandomColor(inlinePolygonOptions.getFillColor()));
    }
}
 
Example 8
Source Project: geopackage-android-map   Source File: StyleUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Create new polygon options populated with the feature style
 *
 * @param featureStyle feature style
 * @param density      display density: {@link android.util.DisplayMetrics#density}
 * @return polygon options populated with the feature style
 */
public static PolygonOptions createPolygonOptions(FeatureStyle featureStyle, float density) {

    PolygonOptions polygonOptions = new PolygonOptions();
    setFeatureStyle(polygonOptions, featureStyle, density);

    return polygonOptions;
}
 
Example 9
Source Project: geopackage-android-map   Source File: StyleUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Create new polygon options populated with the style
 *
 * @param style   style row
 * @param density display density: {@link android.util.DisplayMetrics#density}
 * @return polygon options populated with the style
 */
public static PolygonOptions createPolygonOptions(StyleRow style, float density) {

    PolygonOptions polygonOptions = new PolygonOptions();
    setStyle(polygonOptions, style, density);

    return polygonOptions;
}
 
Example 10
Source Project: geopackage-android-map   Source File: MapUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Is the point on the multi polygon
 *
 * @param point        point
 * @param multiPolygon multi polygon
 * @param geodesic     geodesic check flag
 * @param tolerance    distance tolerance
 * @return true if on the multi polygon
 */
public static boolean isPointOnMultiPolygon(LatLng point, MultiPolygonOptions multiPolygon, boolean geodesic, double tolerance) {
    boolean near = false;
    for (PolygonOptions polygon : multiPolygon.getPolygonOptions()) {
        near = isPointOnPolygon(point, polygon, geodesic, tolerance);
        if (near) {
            break;
        }
    }
    return near;
}
 
Example 11
Source Project: geopackage-android-map   Source File: GoogleMapShapeConverter.java    License: MIT License 5 votes vote down vote up
/**
 * Convert a {@link MultiPolygon} to a {@link MultiPolygonOptions}
 *
 * @param multiPolygon multi polygon
 * @return multi polygon options
 */
public MultiPolygonOptions toPolygons(MultiPolygon multiPolygon) {

    MultiPolygonOptions polygons = new MultiPolygonOptions();

    for (Polygon polygon : multiPolygon.getPolygons()) {
        PolygonOptions polygonOptions = toPolygon(polygon);
        polygons.add(polygonOptions);
    }

    return polygons;
}
 
Example 12
Source Project: geopackage-android-map   Source File: GoogleMapShapeConverter.java    License: MIT License 5 votes vote down vote up
/**
 * Convert a list of {@link PolygonOptions} to a {@link MultiPolygon}
 *
 * @param multiPolygonOptions multi polygon options
 * @param hasZ                has z flag
 * @param hasM                has m flag
 * @return multi polygon
 */
public MultiPolygon toMultiPolygonFromOptions(
        MultiPolygonOptions multiPolygonOptions, boolean hasZ, boolean hasM) {

    MultiPolygon multiPolygon = new MultiPolygon(hasZ, hasM);

    for (PolygonOptions mapPolygon : multiPolygonOptions
            .getPolygonOptions()) {
        Polygon polygon = toPolygon(mapPolygon);
        multiPolygon.addPolygon(polygon);
    }

    return multiPolygon;
}
 
Example 13
Source Project: geopackage-android-map   Source File: GoogleMapShapeConverter.java    License: MIT License 5 votes vote down vote up
/**
 * Convert a {@link PolyhedralSurface} to a {@link MultiPolygonOptions}
 *
 * @param polyhedralSurface polyhedral surface
 * @return multi polygon options
 */
public MultiPolygonOptions toPolygons(PolyhedralSurface polyhedralSurface) {

    MultiPolygonOptions polygons = new MultiPolygonOptions();

    for (Polygon polygon : polyhedralSurface.getPolygons()) {
        PolygonOptions polygonOptions = toPolygon(polygon);
        polygons.add(polygonOptions);
    }

    return polygons;
}
 
Example 14
Source Project: geopackage-android-map   Source File: GoogleMapShapeConverter.java    License: MIT License 5 votes vote down vote up
/**
 * Convert a {@link MultiPolygonOptions} to a {@link PolyhedralSurface}
 *
 * @param multiPolygonOptions multi polygon options
 * @param hasZ                has z flag
 * @param hasM                has m flag
 * @return polyhedral surface
 */
public PolyhedralSurface toPolyhedralSurfaceWithOptions(
        MultiPolygonOptions multiPolygonOptions, boolean hasZ, boolean hasM) {

    PolyhedralSurface polyhedralSurface = new PolyhedralSurface(hasZ, hasM);

    for (PolygonOptions mapPolygon : multiPolygonOptions
            .getPolygonOptions()) {
        Polygon polygon = toPolygon(mapPolygon);
        polyhedralSurface.addPolygon(polygon);
    }

    return polyhedralSurface;
}
 
Example 15
Source Project: geopackage-android-map   Source File: GoogleMapShapeConverter.java    License: MIT License 5 votes vote down vote up
/**
 * Add a Polygon to the map as markers
 *
 * @param shapeMarkers             google map shape markers
 * @param map                      google map
 * @param polygonOptions           polygon options
 * @param polygonMarkerOptions     polygon marker options
 * @param polygonMarkerHoleOptions polygon marker hole options
 * @param globalPolygonOptions     global polygon options
 * @return polygon markers
 */
public PolygonMarkers addPolygonToMapAsMarkers(
        GoogleMapShapeMarkers shapeMarkers, GoogleMap map,
        PolygonOptions polygonOptions, MarkerOptions polygonMarkerOptions,
        MarkerOptions polygonMarkerHoleOptions,
        PolygonOptions globalPolygonOptions) {

    PolygonMarkers polygonMarkers = new PolygonMarkers(this);

    if (globalPolygonOptions != null) {
        polygonOptions.fillColor(globalPolygonOptions.getFillColor());
        polygonOptions.strokeColor(globalPolygonOptions.getStrokeColor());
        polygonOptions.geodesic(globalPolygonOptions.isGeodesic());
        polygonOptions.visible(globalPolygonOptions.isVisible());
        polygonOptions.zIndex(globalPolygonOptions.getZIndex());
        polygonOptions.strokeWidth(globalPolygonOptions.getStrokeWidth());
    }

    com.google.android.gms.maps.model.Polygon polygon = addPolygonToMap(
            map, polygonOptions);
    polygonMarkers.setPolygon(polygon);

    List<Marker> markers = addPointsToMapAsMarkers(map,
            polygon.getPoints(), polygonMarkerOptions, true);
    polygonMarkers.setMarkers(markers);

    for (List<LatLng> holes : polygon.getHoles()) {
        List<Marker> holeMarkers = addPointsToMapAsMarkers(map, holes,
                polygonMarkerHoleOptions, true);
        PolygonHoleMarkers polygonHoleMarkers = new PolygonHoleMarkers(
                polygonMarkers);
        polygonHoleMarkers.setMarkers(holeMarkers);
        shapeMarkers.add(polygonHoleMarkers);
        polygonMarkers.addHole(polygonHoleMarkers);
    }

    return polygonMarkers;
}
 
Example 16
/**
 * Test the Polygon conversion
 * 
 * @param converter
 * @param polygon
 */
private static void convertPolygon(GoogleMapShapeConverter converter,
		Polygon polygon) {

	PolygonOptions polygonOptions = converter.toPolygon(polygon);
	TestCase.assertNotNull(polygonOptions);

	comparePolygonAndMapPolygon(converter, polygon, polygonOptions);

	Polygon polygon2 = converter.toPolygon(polygonOptions);
	comparePolygons(polygon, polygon2);
}
 
Example 17
/**
 * Compare list of polygons with list of map polygons
 *
    * @param converter
 * @param polygons
 * @param mapPolygons
 */
private static void comparePolygonsAndMapPolygons(GoogleMapShapeConverter converter, List<Polygon> polygons,
		List<PolygonOptions> mapPolygons) {

	TestCase.assertEquals(polygons.size(), mapPolygons.size());
	for (int i = 0; i < polygons.size(); i++) {
		comparePolygonAndMapPolygon(converter, polygons.get(i), mapPolygons.get(i));
	}

}
 
Example 18
Source Project: mage-android   Source File: MapObservationManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Set the polygon options
 *
 * @param style          shape style
 * @param polygonOptions polygon options
 * @param visible        visible flag
 */
private void setPolygonOptions(ObservationShapeStyle style, PolygonOptions polygonOptions, boolean visible) {
    polygonOptions.strokeWidth(style.getStrokeWidth());
    polygonOptions.strokeColor(style.getStrokeColor());
    polygonOptions.fillColor(style.getFillColor());
    polygonOptions.visible(visible);
    polygonOptions.geodesic(MapShapeObservation.GEODESIC);
}
 
Example 19
private void drawPolygon( LatLng startingLocation ) {
    LatLng point2 = new LatLng( startingLocation.latitude + .001, startingLocation.longitude );
    LatLng point3 = new LatLng( startingLocation.latitude, startingLocation.longitude + .001 );

    PolygonOptions options = new PolygonOptions();
    options.add(startingLocation, point2, point3);

    options.fillColor( getResources().getColor( R.color.fill_color ) );
    options.strokeColor( getResources().getColor( R.color.stroke_color ) );
    options.strokeWidth( 10 );

    getMap().addPolygon(options);
}
 
Example 20
Source Project: android-samples   Source File: LiteDemoActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Add a Polyline and a Polygon to the map.
 * The Polyline connects Melbourne, Adelaide and Perth. The Polygon is located in the Northern
 * Territory (Australia).
 */
private void addPolyObjects() {
    map.addPolyline((new PolylineOptions())
            .add(MELBOURNE, ADELAIDE, PERTH)
            .color(Color.GREEN)
            .width(5f));

    map.addPolygon(new PolygonOptions()
            .add(POLYGON)
            .fillColor(Color.CYAN)
            .strokeColor(Color.BLUE)
            .strokeWidth(5));
}
 
Example 21
Source Project: AndroidDemoProjects   Source File: MapFragment.java    License: Apache License 2.0 5 votes vote down vote up
private void drawPolygon( LatLng startingLocation ) {
    LatLng point2 = new LatLng( startingLocation.latitude + .001, startingLocation.longitude );
    LatLng point3 = new LatLng( startingLocation.latitude, startingLocation.longitude + .001 );

    PolygonOptions options = new PolygonOptions();
    options.add(startingLocation, point2, point3);

    options.fillColor( getResources().getColor( R.color.fill_color ) );
    options.strokeColor( getResources().getColor( R.color.stroke_color ) );
    options.strokeWidth( 10 );

    getMap().addPolygon(options);
}
 
Example 22
Source Project: android-maps-utils   Source File: Renderer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Adds a DataPolygon to the map as a Polygon
 *
 * @param polygonOptions
 * @param polygon        contains coordinates for the Polygon
 * @return Polygon object created from given DataPolygon
 */
private Polygon addPolygonToMap(PolygonOptions polygonOptions, DataPolygon polygon) {
    // First array of coordinates are the outline
    polygonOptions.addAll(polygon.getOuterBoundaryCoordinates());
    // Following arrays are holes
    List<List<LatLng>> innerBoundaries = polygon.getInnerBoundaryCoordinates();
    for (List<LatLng> innerBoundary : innerBoundaries) {
        polygonOptions.addHole(innerBoundary);
    }
    Polygon addedPolygon = mPolygons.addPolygon(polygonOptions);
    addedPolygon.setClickable(polygonOptions.isClickable());
    return addedPolygon;
}
 
Example 23
Source Project: android-maps-utils   Source File: Style.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new Style object
 */
public Style() {
    mMarkerOptions = new MarkerOptions();
    mPolylineOptions = new PolylineOptions();
    mPolylineOptions.clickable(true);
    mPolygonOptions = new PolygonOptions();
    mPolygonOptions.clickable(true);
}
 
Example 24
Source Project: android-maps-utils   Source File: GeoJsonPolygonStyle.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets a new PolygonOptions object containing styles for the GeoJsonPolygon
 *
 * @return new PolygonOptions object
 */
public PolygonOptions toPolygonOptions() {
    PolygonOptions polygonOptions = new PolygonOptions();
    polygonOptions.fillColor(mPolygonOptions.getFillColor());
    polygonOptions.geodesic(mPolygonOptions.isGeodesic());
    polygonOptions.strokeColor(mPolygonOptions.getStrokeColor());
    polygonOptions.strokeJointType(mPolygonOptions.getStrokeJointType());
    polygonOptions.strokePattern(mPolygonOptions.getStrokePattern());
    polygonOptions.strokeWidth(mPolygonOptions.getStrokeWidth());
    polygonOptions.visible(mPolygonOptions.isVisible());
    polygonOptions.zIndex(mPolygonOptions.getZIndex());
    polygonOptions.clickable(mPolygonOptions.isClickable());
    return polygonOptions;
}
 
Example 25
Source Project: android-maps-utils   Source File: KmlPlacemark.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets a PolygonOption
 *
 * @return new PolygonOptions
 */
public PolygonOptions getPolygonOptions() {
    if (mInlineStyle == null) {
        return null;
    }
    return mInlineStyle.getPolygonOptions();
}
 
Example 26
Source Project: android-maps-utils   Source File: KmlStyle.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new PolygonOption from given properties of an existing PolygonOption
 *
 * @param originalPolygonOption An existing PolygonOption instance
 * @param isFill                Whether the fill for a polygon is set
 * @param isOutline             Whether the outline for a polygon is set
 * @return A new PolygonOption
 */
private static PolygonOptions createPolygonOptions(PolygonOptions originalPolygonOption,
                                                   boolean isFill, boolean isOutline) {
    PolygonOptions polygonOptions = new PolygonOptions();
    if (isFill) {
        polygonOptions.fillColor(originalPolygonOption.getFillColor());
    }
    if (isOutline) {
        polygonOptions.strokeColor(originalPolygonOption.getStrokeColor());
        polygonOptions.strokeWidth(originalPolygonOption.getStrokeWidth());
    }
    polygonOptions.clickable(originalPolygonOption.isClickable());
    return polygonOptions;
}
 
Example 27
Source Project: effective_android_sample   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 戦場1つを描画する
 */
private void drawField(Field field) {
    // マーカー定義
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.title(field.getName()); // 名前を設定
    markerOptions.snippet(field.getMemo()); // 説明を設定
    markerOptions.position(calcCenter(field.getVertexes())); // マーカーの座標を設定(区画の中心を自動算出)
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(field.getColorHue())); // 色を設定

    // マップにマーカーを追加
    mGoogleMap.addMarker(markerOptions);

    // 区画を描画
    final LatLng[] vertexes = field.getVertexes();
    if (vertexes != null && vertexes.length > 3) {
        // ポリゴン定義
        PolygonOptions polygonOptions = new PolygonOptions();

        // RGBそれぞれの色を作成
        final int[] colorRgb = field.getColorRgb();
        int colorRed = colorRgb[0];
        int colorGreen = colorRgb[1];
        int colorBlue = colorRgb[2];

        // 区画の輪郭について設定
        polygonOptions.strokeColor(Color.argb(0x255, colorRed, colorGreen, colorBlue));
        polygonOptions.strokeWidth(5);

        // 区画の塗りつぶしについて設定
        polygonOptions.fillColor(Color.argb(0x40, colorRed, colorGreen, colorBlue));

        // 各頂点の座標を設定
        polygonOptions.add(vertexes); // LatLngでもLatLng[]でもOK

        // マップにポリゴンを追加
        mGoogleMap.addPolygon(polygonOptions);
    }
}
 
Example 28
Source Project: FimiX8-RE   Source File: GglMapNoFlyZone.java    License: MIT License 4 votes vote down vote up
public void drawCandyNoFlyZone(LatLng[] lats) {
    PolygonOptions options = new PolygonOptions();
}
 
Example 29
Source Project: geopackage-android-map   Source File: MapUtils.java    License: MIT License 4 votes vote down vote up
/**
 * Is the point on or near the shape
 *
 * @param point     lat lng point
 * @param shape     map shape
 * @param geodesic  geodesic check flag
 * @param tolerance distance tolerance
 * @return true if point is on shape
 */
public static boolean isPointOnShape(LatLng point,
                                     GoogleMapShape shape, boolean geodesic, double tolerance) {

    boolean onShape = false;

    switch (shape.getShapeType()) {

        case LAT_LNG:
            onShape = isPointNearPoint(point, (LatLng) shape.getShape(), tolerance);
            break;
        case MARKER_OPTIONS:
            onShape = isPointNearMarker(point, (MarkerOptions) shape.getShape(), tolerance);
            break;
        case POLYLINE_OPTIONS:
            onShape = isPointOnPolyline(point, (PolylineOptions) shape.getShape(), geodesic, tolerance);
            break;
        case POLYGON_OPTIONS:
            onShape = isPointOnPolygon(point, (PolygonOptions) shape.getShape(), geodesic, tolerance);
            break;
        case MULTI_LAT_LNG:
            onShape = isPointNearMultiLatLng(point, (MultiLatLng) shape.getShape(), tolerance);
            break;
        case MULTI_POLYLINE_OPTIONS:
            onShape = isPointOnMultiPolyline(point, (MultiPolylineOptions) shape.getShape(), geodesic, tolerance);
            break;
        case MULTI_POLYGON_OPTIONS:
            onShape = isPointOnMultiPolygon(point, (MultiPolygonOptions) shape.getShape(), geodesic, tolerance);
            break;
        case COLLECTION:
            @SuppressWarnings("unchecked")
            List<GoogleMapShape> shapeList = (List<GoogleMapShape>) shape
                    .getShape();
            for (GoogleMapShape shapeListItem : shapeList) {
                onShape = isPointOnShape(point, shapeListItem, geodesic, tolerance);
                if (onShape) {
                    break;
                }
            }
            break;
        default:
            throw new GeoPackageException("Unsupported Shape Type: "
                    + shape.getShapeType());

    }

    return onShape;
}
 
Example 30
Source Project: geopackage-android-map   Source File: GoogleMapShape.java    License: MIT License 4 votes vote down vote up
/**
 * Updates visibility of all objects
 *
 * @param visible visible flag
 * @since 1.3.2
 */
public void setVisible(boolean visible) {

    switch (shapeType) {

        case MARKER_OPTIONS:
            ((MarkerOptions) shape).visible(visible);
            break;
        case POLYLINE_OPTIONS:
            ((PolylineOptions) shape).visible(visible);
            break;
        case POLYGON_OPTIONS:
            ((PolygonOptions) shape).visible(visible);
            break;
        case MULTI_POLYLINE_OPTIONS:
            ((MultiPolylineOptions) shape).visible(visible);
            break;
        case MULTI_POLYGON_OPTIONS:
            ((MultiPolygonOptions) shape).visible(visible);
            break;
        case MARKER:
            ((Marker) shape).setVisible(visible);
            break;
        case POLYGON:
            ((Polygon) shape).setVisible(visible);
            break;
        case POLYLINE:
            ((Polyline) shape).setVisible(visible);
            break;
        case MULTI_MARKER:
            ((MultiMarker) shape).setVisible(visible);
            break;
        case MULTI_POLYLINE:
            ((MultiPolyline) shape).setVisible(visible);
            break;
        case MULTI_POLYGON:
            ((MultiPolygon) shape).setVisible(visible);
            break;
        case POLYLINE_MARKERS:
            ((PolylineMarkers) shape).setVisible(visible);
            break;
        case POLYGON_MARKERS:
            ((PolygonMarkers) shape).setVisible(visible);
            break;
        case MULTI_POLYLINE_MARKERS:
            ((MultiPolylineMarkers) shape).setVisible(visible);
            break;
        case MULTI_POLYGON_MARKERS:
            ((MultiPolygonMarkers) shape).setVisible(visible);
            break;
        case COLLECTION:
            @SuppressWarnings("unchecked")
            List<GoogleMapShape> shapeList = (List<GoogleMapShape>) shape;
            for (GoogleMapShape shapeListItem : shapeList) {
                shapeListItem.setVisible(visible);
            }
            break;
        default:
    }

}