相关疑难解决方法(0)

更改Google Maps API的"我的位置"按钮的位置

我正在使用谷歌地图Android API v2,我需要一种方法来获取"我的位置"按钮的位置.

我得到这样的"我的位置"按钮:

GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
final GoogleMap map = ((SupportMapFragment) getSupportFragmentManager()
        .findFragmentById(R.id.map)).getMap();

// This gets the button
map.setMyLocationEnabled(true);
Run Code Online (Sandbox Code Playgroud)

java android google-maps-android-api-2 android-maps-v2

83
推荐指数
9
解决办法
7万
查看次数

如何在运行时请求位置权限

在清单文件中,我添加了粗略和精细的权限,当我在使用Android 6的设备上运行时,没有任何反应!我尝试了一切,但无法获得位置更新......

我究竟做错了什么?

public class MainActivity extends AppCompatActivity implements LocationListener {

    LocationManager locationManager;
    String provider;

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

        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

        provider = locationManager.getBestProvider(new Criteria(), false);

        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            // TODO: Consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. …
Run Code Online (Sandbox Code Playgroud)

java android

51
推荐指数
4
解决办法
11万
查看次数

GoogleMaps v2 Android的我的位置按钮,未显示

我正在使用谷歌地图做一个应用程序,但当我尝试添加"我的位置"按钮,因为参考说不起作用...

多数民众赞成我怎么做:

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

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

        locManager = (LocationManager)getSystemService(LOCATION_SERVICE);
        providersList = locManager.getAllProviders();
        provider =locManager.getProvider(providersList.get(0));
        precision = provider.getAccuracy();
        req = new Criteria();
        req.setAccuracy(Criteria.ACCURACY_FINE);        
        inside = false;

        map.getUiSettings().setMyLocationButtonEnabled(true);

        buildPolygon();
        drawPolygon();
        startLocalization();
    }
Run Code Online (Sandbox Code Playgroud)

我用map.getUiSettings().setMyLocationButtonEnabled(true);谷歌的参考作为节目.我不知道发生了什么......

java android google-maps

30
推荐指数
1
解决办法
3万
查看次数

用户之后的地图视图 - 适用于Android Maps API v2的MyLocationOverlay类型功能

我切换到Android版地图的v2,我正在尝试移植以下功能:

使用MyLocationOverlay,我可以显示设备的当前位置(蓝点).当用户的位置发生变化并且点到达可见区域的边缘时,地图会动画显示,以便点实时地成为视图的中心.

在v2中,我使用了SupportMapFragment和getMap().setMyLocationEnabled(true).当前位置显示为蓝点(箭头),但是当设备更改位置时,地图视图不会移动,并且点最终会离开视图.

有任何想法吗?

api maps android google-maps-android-api-2

16
推荐指数
2
解决办法
3万
查看次数