Code example for GoogleMap

Methods: addPolygon, moveCamera

0
                setUpMap(); 
            } 
        } 
    } 
 
    private void setUpMap() { 
        // Create a rectangle with two rectangular holes. 
        mMap.addPolygon(new PolygonOptions()
                .addAll(createCWRectangle(new LatLng(-20, 130), 5, 5))
                .addHole(createCWRectangle(new LatLng(-22, 128), 1, 1))
                .addHole(createCWRectangle(new LatLng(-18, 133), 0.5, 1.5))
                .fillColor(Color.CYAN)
                .strokeColor(Color.BLUE)
                .strokeWidth(5));
 
        // Create an ellipse centered at Sydney. 
        PolygonOptions options = new PolygonOptions();
        int numPoints = 400;
        float semiHorizontalAxis = 10f;
        float semiVerticalAxis = 5f;
        double phase = 2 * Math.PI / numPoints;
        for (int i = 0; i <= numPoints; i++) {
            options.add(new LatLng(SYDNEY.latitude + semiVerticalAxis * Math.sin(i * phase),
                    SYDNEY.longitude + semiHorizontalAxis * Math.cos(i * phase)));
        } 
 
        int fillColor = Color.HSVToColor(
                mAlphaBar.getProgress(), new float[] {mColorBar.getProgress(), 1, 1});
        mMutablePolygon = mMap.addPolygon(options
                .strokeWidth(mWidthBar.getProgress())
                .strokeColor(Color.BLACK)
                .fillColor(fillColor));
 
        mColorBar.setOnSeekBarChangeListener(this);