Android 地图标记点和位置不';棉花糖上不显影
在我的地图应用程序中,它不显示棉花糖上的位置,但它完全在棉花糖下面显示位置和所有标记点Android 地图标记点和位置不';棉花糖上不显影,android,google-maps,location,Android,Google Maps,Location,在我的地图应用程序中,它不显示棉花糖上的位置,但它完全在棉花糖下面显示位置和所有标记点 context = MapsActivity.this; if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
context = MapsActivity.this;
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mMap = googleMap;
//drawing marker
pointOne = new LatLng(23.10, 72.50847684);
mMap.addMarker(new MarkerOptions().position(pointOne).title("Point 1"));
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.ACCESS_FINE_LOCATION)) {
Toast.makeText(this,"Permission IS required",Toast.LENGTH_SHORT).show();
}
return;
}
在这里,我授予了所有运行时权限,但我无法查看当前位置。
提前感谢您的帮助。请尝试此代码,并检查是否授予运行时权限
它对棉花糖版本brother的许可问题
希望这能起作用。您能否确认检查权限并在未授予时返回的if语句没有导致此问题。在那里添加一个调试语句,并确认它没有被打印(因为如果打印了,则意味着权限不受影响)。位置\权限\请求\代码???这是为了什么以及如何实现您正在使用map的活动,您必须在map.getMap()方法之后编写此方法,以授予android棉花糖的权限。
ActivityCompat.requestPermissions(getActivity(), new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_COARSE_LOCATION},
LOCATION_PERMISSION_REQUEST_CODE);