Android谷歌地图 - 删除位置精度圈 [英] Android Google Maps - remove location accuracy circle

查看:196
本文介绍了Android谷歌地图 - 删除位置精度圈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

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

申请地点:

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

我想要做的是仅显示当前位置的标记,而不是指示位置的圆圈准确性。我仔细查看了文档和API参考,并且四处搜索,还没有找到一个选项来关闭它。

解决方案

在地图上的蓝色圆圈是启用eith以下行:

  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,并根据需要执行相同操作。


I'm displaying a Google map (v2 API) in an Android app like so:

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

Requesting location:

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

What I want to do is show just the marker for the current location, and not the circle indicating location accuracy. I've looked through the documentation and API reference, and searched around and haven't found an option to turn that off.

解决方案

The blue circle on the map is enabled eith the following line:

map.setMyLocationEnabled(true);

You only have to set it to false and it will disappear:

map.setMyLocationEnabled(false);

To draw your marker you need to get the users location using a listener. You can do something like this:

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);

You can also use your LocationClient and do the same if you need to.

这篇关于Android谷歌地图 - 删除位置精度圈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆