Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android SupportMapFragment重写setOnMyLocationChangeListener_Android_Supportmapfragment - Fatal编程技术网

Android SupportMapFragment重写setOnMyLocationChangeListener

Android SupportMapFragment重写setOnMyLocationChangeListener,android,supportmapfragment,Android,Supportmapfragment,我正在尝试使用以下命令覆盖SupportMapFragment上的setOnMyLocationChangeListener map.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() { @Override public void onMyLocationChange(Location location) {

我正在尝试使用以下命令覆盖SupportMapFragment上的setOnMyLocationChangeListener

map.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
                    @Override
                    public void onMyLocationChange(Location location) {
                        LatLng you = new LatLng(location.getLatitude(), location.getLongitude());
                        float distanceTo = location.distanceTo(venueLocation);
                        String miles = metersToMiles(distanceTo);
                        dist.setText(miles + " miles away");
                        LatLngBounds.Builder builder = new LatLngBounds.Builder();
                        map.clear();
                        map.addMarker(new MarkerOptions()
                                .position(venue)
                                .title(centerName)
                                .icon(BitmapDescriptorFactory
                                        .fromResource(R.drawable.fu_map_marker)));
                        map.addMarker(new MarkerOptions()
                                .title("You are here")
                                .position(you));
                        builder.include(venue);
                        builder.include(you);
                        LatLngBounds bounds = builder.build();
                        map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 75));
                    }
                });

但是,在摄影机使用LatLngBounds设置动画之前,它会自动缩放到用户位置,并添加一个蓝点。我是否可以禁用此功能?

之所以这样做,是因为您启用了“我的位置”层。您可以通过禁用它

map.setMyLocationEnabled(false);
也不赞成以这种方式侦听位置更改。最新版本的Google Play services提供了一个新的功能,该功能应能以更少的电池使用量提供相同的功能


之所以这样做,是因为您启用了“我的位置”层。您可以通过禁用它

map.setMyLocationEnabled(false);
也不赞成以这种方式侦听位置更改。最新版本的Google Play services提供了一个新的功能,该功能应能以更少的电池使用量提供相同的功能


谢谢,我现在就去看看:)谢谢,我现在就去看看:)