Android Google地图未显示圆圈绘制

时间:2014-10-27 11:29:45

标签: android google-maps

我正在尝试使用此代码

在标记位置绘制圆圈
 private void setMarker() {
        if (nMarker != null) {
            removeMapContents();
        }
        Address nAddress = CommonObjects.getCurrentMyPlace().getPlaceAddress();
        setPlaceContents();
        LatLng ll = new LatLng(nAddress.getLatitude(), nAddress.getLongitude());
        nCircle = drawCircle(ll);
        MarkerOptions nMarkerOptions = new MarkerOptions()
                .title(nAddress.getLocality())
                .position(ll)
                .draggable(true);
        nMarker = CommonObjects.getMap().addMarker(nMarkerOptions);
    }

private Circle drawCircle(LatLng ll) {
    CircleOptions nCircleOptions = new CircleOptions().center(ll)
            .radius(Constants.DEFAULT_RADIUS_VALUE)
            .fillColor(Color.BLACK)
            .strokeColor(Constants.DEFAULT_RADIUS_STROKE_COLOR)
            .strokeWidth(Constants.DEFAULT_RADIUS_STROKE_WIDTH);    
    return CommonObjects.getMap().addCircle(nCircleOptions);
}

此处的值取自此类

    public class Constants {
        public static final int GPS_ERRORIALOG_REQUEST = 9001;
        public static final float DEFAULT_ZOOM = 5;
        public static final int DEFAULT_RADIUS_INDEX = 5;
        public static final String DEFAULT_RADIUS = "Radius 500 Meters";
        public static final int DEFAULT_SPINNER_INDEX = 0;
        public static final String DEFAULT_CONTACT = "Select Contact";
        public static final String DEFAULT_MESSAGE = "Enter Message";
        public static final boolean DEFAULT_NOTIFICATION_CHECK = false;
        public static final double DEFAULT_RADIUS_VALUE = 1000;
        public static final int DEFAULT_RADIUS_STROKE_COLOR = Color.BLUE;
        public static final int DEFAULT_RADIUS_FILL_COLOR = 0x330000FF;
        public static final float DEFAULT_RADIUS_STROKE_WIDTH = 3;

    }

代码成功运行并且没有发生错误,但也没有在标记位置上绘制圆圈。

1 个答案:

答案 0 :(得分:1)

我已经解决了问题我的DEFAULT_ZOOM值很小,所以我将它从5增加到14,现在显示DEFAULT_RADIUS值为500米的圆圈。