@Override public void onLocationPermissionsGranted() { //noinspection MissingPermission googleMap.setMyLocationEnabled(myLocationEnabled); }
private void setUpMap() { map.setMyLocationEnabled(true); map.animateCamera(zoomToLastKnownLatLng()); }
@Override @SuppressWarnings("MissingPermission") public void onMapReady(GoogleMap googleMap) { map = googleMap; map.getUiSettings().setMapToolbarEnabled(false); if (listener.hasLocationPermission()) { map.setMyLocationEnabled(true); map.getUiSettings().setMyLocationButtonEnabled(false); } map.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { if (marker.getTag() instanceof Place) { Place place = (Place) marker.getTag(); listener.onPlaceSelected(place); } } }); if (state == State.MAP) { displayPlaces(placesToDisplay); } }
@SuppressLint("MissingPermission") @Override public void onMapReady(final GoogleMap map) { this.map=map; if (needsInit) { CameraUpdate center= CameraUpdateFactory.newLatLng(new LatLng(40.76793169992044, -73.98180484771729)); CameraUpdate zoom=CameraUpdateFactory.zoomTo(15); map.moveCamera(center); map.animateCamera(zoom); } addMarker(map, 40.748963847316034, -73.96807193756104, R.string.un, R.string.united_nations); addMarker(map, 40.76866299974387, -73.98268461227417, R.string.lincoln_center, R.string.lincoln_center_snippet); addMarker(map, 40.765136435316755, -73.97989511489868, R.string.carnegie_hall, R.string.practice_x3); addMarker(map, 40.70686417491799, -74.01572942733765, R.string.downtown_club, R.string.heisman_trophy); map.setInfoWindowAdapter(new PopupAdapter(getLayoutInflater())); map.setOnInfoWindowClickListener(this); map.setMyLocationEnabled(true); locMgr=(LocationManager)getSystemService(LOCATION_SERVICE); crit.setAccuracy(Criteria.ACCURACY_FINE); follow(); }
@Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] results) { if (requestCode != LOCATION_PERMISSION_REQUEST_CODE) { return; } if (PermissionUtils.isPermissionGranted(permissions, results, Manifest.permission.ACCESS_FINE_LOCATION)) { mMap.setMyLocationEnabled(true); mMyLocationCheckbox.setChecked(true); } else { mShowPermissionDeniedDialog = true; } }
/** * Enables the My Location layer if the fine location permission has been granted. */ private void enableMyLocation() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Permission to access the location is missing. PermissionUtils.requestPermission(this, LOCATION_PERMISSION_REQUEST_CODE, Manifest.permission.ACCESS_FINE_LOCATION, true); } else if (mMap != null) { // Access to the location has been granted to the app. mMap.setMyLocationEnabled(true); } }
private void updateMyLocation() { if (!checkReady()) { return; } if (!mMyLocationCheckbox.isChecked()) { mMap.setMyLocationEnabled(false); return; } // Enable the location layer. Request the location permission if needed. if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { mMap.setMyLocationEnabled(true); } else { // Uncheck the box until the layer has been enabled and request missing permission. mMyLocationCheckbox.setChecked(false); PermissionUtils.requestPermission(this, LOCATION_PERMISSION_REQUEST_CODE, Manifest.permission.ACCESS_FINE_LOCATION, false); } }
public void setMyLocationLayerEnabled(View v) { if (!checkReady()) { return; } // Enables/disables the my location layer (i.e., the dot/chevron on the map). If enabled, it // will also cause the my location button to show (if it is enabled); if disabled, the my // location button will never show. if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { mMap.setMyLocationEnabled(mMyLocationLayerCheckbox.isChecked()); } else { // Uncheck the box and request missing location permission. mMyLocationLayerCheckbox.setChecked(false); PermissionUtils.requestPermission(this, LOCATION_LAYER_PERMISSION_REQUEST_CODE, Manifest.permission.ACCESS_FINE_LOCATION, false); } }
@Override public void onMapReady(GoogleMap map) { map.setLocationSource(mLocationSource); map.setOnMapLongClickListener(mLocationSource); map.setMyLocationEnabled(true); } }
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (requestCode == MY_LOCATION_PERMISSION_REQUEST_CODE) { // Enable the My Location button if the permission has been granted. if (PermissionUtils.isPermissionGranted(permissions, grantResults, Manifest.permission.ACCESS_FINE_LOCATION)) { mUiSettings.setMyLocationButtonEnabled(true); mMyLocationButtonCheckbox.setChecked(true); } else { mLocationPermissionDenied = true; } } else if (requestCode == LOCATION_LAYER_PERMISSION_REQUEST_CODE) { // Enable the My Location layer if the permission has been granted. if (PermissionUtils.isPermissionGranted(permissions, grantResults, Manifest.permission.ACCESS_FINE_LOCATION)) { mMap.setMyLocationEnabled(true); mMyLocationLayerCheckbox.setChecked(true); } else { mLocationPermissionDenied = true; } } }
/** * Updates the map's UI settings based on whether the user has granted location permission. */ private void updateLocationUI() { if (mMap == null) { return; } try { if (mLocationPermissionGranted) { mMap.setMyLocationEnabled(true); mMap.getUiSettings().setMyLocationButtonEnabled(true); } else { mMap.setMyLocationEnabled(false); mMap.getUiSettings().setMyLocationButtonEnabled(false); mLastKnownLocation = null; getLocationPermission(); } } catch (SecurityException e) { Log.e("Exception: %s", e.getMessage()); } } }
@RequiresPermission(Manifest.permission.ACCESS_FINE_LOCATION) private void onLocationPermissionGranted() { if (!checkPermission()) return; mMap.getUiSettings().setMyLocationButtonEnabled(false); mMap.setMyLocationEnabled(true); mFusedLocationClient.getLastLocation() .addOnSuccessListener(this, new OnSuccessListener<Location>() { @Override public void onSuccess(Location location) { if (location != null) { userLocation = location; CameraPosition cameraPosition = new CameraPosition.Builder() .target(new LatLng(userLocation.getLatitude(), userLocation.getLongitude())) .zoom(17) .build(); addOverlay(new LatLng(userLocation.getLatitude(), userLocation.getLongitude())); mMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); } else { userLocation = null; } } }); }
@Override public void onMapReady(GoogleMap map) { mMap = map; mUiSettings = mMap.getUiSettings(); // Keep the UI Settings state in sync with the checkboxes. mUiSettings.setZoomControlsEnabled(isChecked(R.id.zoom_buttons_toggle)); mUiSettings.setCompassEnabled(isChecked(R.id.compass_toggle)); mUiSettings.setMyLocationButtonEnabled(isChecked(R.id.mylocationbutton_toggle)); mMap.setMyLocationEnabled(isChecked(R.id.mylocationlayer_toggle)); mUiSettings.setScrollGesturesEnabled(isChecked(R.id.scroll_toggle)); mUiSettings.setZoomGesturesEnabled(isChecked(R.id.zoom_gestures_toggle)); mUiSettings.setTiltGesturesEnabled(isChecked(R.id.tilt_toggle)); mUiSettings.setRotateGesturesEnabled(isChecked(R.id.rotate_toggle)); }
@RequiresPermission(Manifest.permission.ACCESS_FINE_LOCATION) @Override public void setMyLocationEnabled(boolean enabled) { map.setMyLocationEnabled(enabled); }
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // do not show Google's outdoor location mMap.setMyLocationEnabled(false); mMap.setOnMapClickListener(this); }
private void enableMyLocation() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Permission to access the location is missing. PermissionUtils.requestPermission(this, LOCATION_PERMISSION_REQUEST_CODE, Manifest.permission.ACCESS_FINE_LOCATION, true); } else if (mMap != null) { // Access to the location has been granted to the app. mMap.setMyLocationEnabled(true); } }
@SuppressWarnings({"MissingPermission"}) private void enableLocationOnMap() { if (mPermissionGranted && mMap != null && !mMap.isMyLocationEnabled()) { mMap.setMyLocationEnabled(true); } }
private void enableMyLocation() { if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Permission to access the location is missing. PermissionUtils.requestPermission(this, LOCATION_PERMISSION_REQUEST_CODE, android.Manifest.permission.ACCESS_FINE_LOCATION, false); } else if (mMap != null) { // Access to the location has been granted to the app. mMap.setMyLocationEnabled(true); autoPositionToCurrentPosition(); } }
private void enableMyLocation() { if (ContextCompat.checkSelfPermission(mContent, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Permission to access the location is missing. PermissionUtils.requestPermission(mActivity, LOCATION_PERMISSION_REQUEST_CODE, android.Manifest.permission.ACCESS_FINE_LOCATION, false); } else if (mMap != null) { // Access to the location has been granted to the app. mMap.setMyLocationEnabled(true); autoPositionToCurrentPosition(); } }
@Override public void onMapReady(GoogleMap googleMap) { mGoogleMap = googleMap; MapsInitializer.initialize(getRootView().getContext()); mGoogleMap.setMyLocationEnabled(false); // Don't show my location mGoogleMap.setBuildingsEnabled(false); // Don't show 3D buildings mGoogleMap.getUiSettings().setMapToolbarEnabled(false); // No toolbar needed in a lite preview if (mLocation != null) { // location has already been bound - bind it to the map setLocation(mLocation); } }