Android 谷歌地图 - 删除位置精度圆

标签 android google-maps

我在 Android 应用程序中显示 Google map (v2 API),如下所示:

mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
                    .getMap();

请求位置:

mLocationClient = new LocationClient(getApplicationContext(), this, this);
                mLocationClient.connect();

我想做的是只显示当前位置的标记,而不是指示位置精度的圆圈。我查看了文档和 API 引用,四处搜索,但没有找到关闭它的选项。

最佳答案

map 上的蓝色圆圈通过以下行启用:

map.setMyLocationEnabled(true);

你只需要将它设置为 false,它就会消失:

map.setMyLocationEnabled(false);

要绘制标记,您需要使用监听器获取用户位置。你可以这样做:

GoogleMap.OnMyLocationChangeListener locationListener = new GoogleMap.OnMyLocationChangeListener() {

            @Override
            public void onMyLocationChange(Location location) {


            drawMarker(location);

            private void drawMarker(Location location) {

                LatLng currentPosition = new LatLng(location.getLatitude(),
                        location.getLongitude());
                map.addMarker(new MarkerOptions()
                        .position(currentPosition)
                        .snippet(
                                "Lat:" + location.getLatitude() + "Lng:"
                                        + location.getLongitude())
                        .icon(BitmapDescriptorFactory
                                .defaultMarker(BitmapDescriptorFactory.HUE_AZURE))
                        .title("position"));

            }

        };

        map.setOnMyLocationChangeListener(locationListener);

您还可以使用您的 LocationClient,并在需要时执行相同的操作。

关于Android 谷歌地图 - 删除位置精度圆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27410463/

相关文章:

android - 无论如何都无法滚动时,如何仅在 RecyclerView 上禁用过度滚动效果?

javascript - 谷歌地图 API : Detecting location and dropping a marker

ios - Mapbox:iOS:根据位置计算剩余的折线点

javascript - Google 不会显示标题

android - 使用 jquerymobile 时,Google map 不会显示在设备上

java - 如何制作 LibGDX + Android Studio jar 文件?

android - 以非零退出值 3 完成

android - 适用于 Android 的预编译 FFmpeg 与使用 Android NDK 构建 FFmpeg

android - Firebase sendPasswordResetEmail 似乎无法与 firebase-auth :9. 0.2 一起正常工作

r - 如何使用 R 的 Google 卫星 View 作为传单中的图 block