我在 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/