Code example for GoogleMap

Methods: addPolygon, moveCamera

0
        } 
    } 
 
    private void setUpMap() { 
        // Create a rectangle with two rectangular holes. 
        mMap.addPolygon(new PolygonOptions()
                .addAll(createRectangle(new LatLng(-20, 130), 5, 5))
                .addHole(createRectangle(new LatLng(-22, 128), 1, 1))
                .addHole(createRectangle(new LatLng(-18, 133), 0.5, 1.5))
                .fillColor(Color.CYAN)
                .strokeColor(Color.BLUE)
                .strokeWidth(5));
 
        // Create a rectangle centered at Sydney. 
        PolygonOptions options = new PolygonOptions().addAll(createRectangle(SYDNEY, 5, 8));
 
        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);
        mAlphaBar.setOnSeekBarChangeListener(this);
        mWidthBar.setOnSeekBarChangeListener(this);
 
        // Move the map so that it is centered on the mutable polygon. 
        mMap.moveCamera(CameraUpdateFactory.newLatLng(SYDNEY));
    } 
 
    /** 
     * Creates a List of LatLngs that form a rectangle with the given dimensions. 
     */