com.google.android.gms.maps.model.Polygon

Here are the examples of the java api class com.google.android.gms.maps.model.Polygon taken from open source projects.

1. GeoJsonRenderer#addPolygonToMap()

Project: wigle-wifi-wardriving
File: GeoJsonRenderer.java
/**
     * Adds a GeoJsonPolygon to the map as a Polygon
     *
     * @param polygonStyle contains relevant styling properties for the Polygon
     * @param polygon      contains coordinates for the Polygon
     * @return Polygon object created from given GeoJsonPolygon
     */
private Polygon addPolygonToMap(GeoJsonPolygonStyle polygonStyle, GeoJsonPolygon polygon) {
    PolygonOptions polygonOptions = polygonStyle.toPolygonOptions();
    // First array of coordinates are the outline
    polygonOptions.addAll(polygon.getCoordinates().get(POLYGON_OUTER_COORDINATE_INDEX));
    // Following arrays are holes
    for (int i = POLYGON_INNER_COORDINATE_INDEX; i < polygon.getCoordinates().size(); i++) {
        polygonOptions.addHole(polygon.getCoordinates().get(i));
    }
    Polygon addedPolygon = mMap.addPolygon(polygonOptions);
    addedPolygon.setClickable(true);
    return addedPolygon;
}

2. GeoJsonRenderer#addPolygonToMap()

Project: android-maps-utils
File: GeoJsonRenderer.java
/**
     * Adds a GeoJsonPolygon to the map as a Polygon
     *
     * @param polygonStyle contains relevant styling properties for the Polygon
     * @param polygon      contains coordinates for the Polygon
     * @return Polygon object created from given GeoJsonPolygon
     */
private Polygon addPolygonToMap(GeoJsonPolygonStyle polygonStyle, GeoJsonPolygon polygon) {
    PolygonOptions polygonOptions = polygonStyle.toPolygonOptions();
    // First array of coordinates are the outline
    polygonOptions.addAll(polygon.getCoordinates().get(POLYGON_OUTER_COORDINATE_INDEX));
    // Following arrays are holes
    for (int i = POLYGON_INNER_COORDINATE_INDEX; i < polygon.getCoordinates().size(); i++) {
        polygonOptions.addHole(polygon.getCoordinates().get(i));
    }
    Polygon addedPolygon = mMap.addPolygon(polygonOptions);
    addedPolygon.setClickable(true);
    return addedPolygon;
}

3. GoogleMapFragment#updatePolygonsPaths()

Project: Tower
File: GoogleMapFragment.java
@Override
public void updatePolygonsPaths(List<List<LatLong>> paths) {
    for (Polygon poly : polygonsPaths) {
        poly.remove();
    }
    for (List<LatLong> contour : paths) {
        PolygonOptions pathOptions = new PolygonOptions();
        pathOptions.strokeColor(POLYGONS_PATH_DEFAULT_COLOR).strokeWidth(POLYGONS_PATH_DEFAULT_WIDTH);
        final List<LatLng> pathPoints = new ArrayList<LatLng>(contour.size());
        for (LatLong coord : contour) {
            pathPoints.add(DroneHelper.CoordToLatLang(coord));
        }
        pathOptions.addAll(pathPoints);
        polygonsPaths.add(getMap().addPolygon(pathOptions));
    }
}

4. NativeGoogleMapFragment#removePolygon()

Project: AirMapView
File: NativeGoogleMapFragment.java
@Override
public <T> void removePolygon(AirMapPolygon<T> polygon) {
    Polygon nativePolygon = polygon.getGooglePolygon();
    if (nativePolygon != null) {
        nativePolygon.remove();
    }
}

5. NativeGoogleMapFragment#addPolygon()

Project: AirMapView
File: NativeGoogleMapFragment.java
@Override
public <T> void addPolygon(AirMapPolygon<T> polygon) {
    Polygon googlePolygon = googleMap.addPolygon(polygon.getPolygonOptions());
    polygon.setGooglePolygon(googlePolygon);
}