【问题标题】:How do I replace my android app Google maps radius circle with a blue translucent one as in image?如何用图像中的蓝色半透明替换我的 android 应用 Google 地图半径圆?
【发布时间】:2014-02-20 12:06:30
【问题描述】:

如何将我的 android 应用 Google 地图半径圆圈替换为蓝色半透明圆圈,如图片中的蓝色标记和蓝色圆圈?

我可以使圆圈具有特定的轮廓和填充,但它看起来并不像下图所示的那样漂亮。我怎么做?到目前为止,我的代码也在下面。

代码:

    private GoogleMap googleMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        try {
            initilizeMap();

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
    private void initilizeMap() {
        if (googleMap == null) {
            googleMap = ((MapFragment) getFragmentManager().findFragmentById(
                    R.id.map)).getMap();


              LatLng latLng = new LatLng(28.982518, -81.542272);
              gooleMap.addMarker(new MarkerOptions().position(latLng));


              Circle circle =  gooleMap.addCircle(new CircleOptions()
              .center(new LatLng(28.982518, -81.542272))
              .radius(1000)
              .strokeColor(Color.RED)
              .fillColor(Color.PURPLE));

mMap.addCircle(new CircleOptions()
        .center(center)
        .radius(radius)
        .strokeWidth(0f)
        .fillColor(0x550000FF));

        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        initilizeMap();
    }

}

Android xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</RelativeLayout>

图片:

为了确认,我想要做的是:

显示上图效果,如上图所示,一个深蓝色的圆圈加上半透明的浅蓝色填充

【问题讨论】:

  • 您在找GoogleMap.setMyLocationEnabled(true) 电话吗?
  • 不抱歉,我正在尝试创建上述效果。带有半透明蓝色的圆形半径
  • 你是什么意思,它看起来一点也不好看……它是什么样子的

标签: java android eclipse google-maps


【解决方案1】:
    CircleOptions circleOptions = new CircleOptions()
        .center(latlng)
        .radius(500)
        .strokeWidth(2)
        .strokeColor(Color.BLUE)
        .fillColor(Color.parseColor("#500084d3"));
        // Supported formats are: #RRGGBB #AARRGGBB
        //   #AA is the alpha, or amount of transparency

    mMap.addCircle(circleOptions);

【讨论】:

  • 这是一个很好的解决方案..有人可以建议我如何在圆圈内添加旋钮。 (第一张图片中的蓝色)。
  • 本示例中的蓝色圆圈图像由 Maps API 提供。它是用户的当前位置。您可以在地图设置中启用或禁用该图标。 public final void setMyLocationEnabled(启用布尔值)developer.android.com/reference/com/google/android/gms/maps/…
猜你喜欢
  • 2021-06-10
  • 2014-04-04
  • 2015-04-25
  • 1970-01-01
  • 2011-07-01
  • 1970-01-01
  • 2022-01-03
  • 2019-05-17
  • 2020-02-26
相关资源
最近更新 更多