Java Code Examples for com.google.android.gms.maps.GoogleMap#setMyLocationEnabled()
The following examples show how to use
com.google.android.gms.maps.GoogleMap#setMyLocationEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GglMap.java From FimiX8-RE with MIT License | 7 votes |
public void onMapReady(GoogleMap googleMap) { this.googleMap = googleMap; this.noFlyZone = new GglMapNoFlyZone(googleMap); googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(this.BEIJING, 9.49f)); if (ContextCompat.checkSelfPermission(this.context, "android.permission.ACCESS_FINE_LOCATION") == 0 || ContextCompat.checkSelfPermission(this.context, "android.permission.ACCESS_COARSE_LOCATION") == 0) { googleMap.setMyLocationEnabled(false); googleMap.getUiSettings().setMyLocationButtonEnabled(false); googleMap.getUiSettings().setCompassEnabled(false); googleMap.getUiSettings().setMapToolbarEnabled(false); googleMap.getUiSettings().setRotateGesturesEnabled(false); this.gglMapLocationManager = new GglMapLocationManager(googleMap, this.context); this.aiP2PManager = new GglMapAiPoint2PointManager(this.context, googleMap, this.gglMapLocationManager); this.aiSurroundManager = new GglMapAiSurroundManager(this.context, googleMap, this.gglMapLocationManager); this.aiLineManager = new GglMapAiLineManager(this.context, googleMap, this.gglMapLocationManager); this.gglMapLocationManager.onStart(); this.isInit = true; if (GlobalConfig.getInstance().getMapStyle() == Constants.X8_GENERAL_MAP_STYLE_NORMAL) { googleMap.setMapType(1); } else if (GlobalConfig.getInstance().getMapStyle() == Constants.X8_GENERAL_MAP_STYLE_SATELLITE) { googleMap.setMapType(2); } } }
Example 2
Source File: LocationDisplayActivity.java From NaviBee with GNU General Public License v3.0 | 6 votes |
@Override public void onMapReady(GoogleMap googleMap) { this.googleMap = googleMap; LatLng location = new LatLng(lat, lon); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)) { googleMap.setMyLocationEnabled(true); } } googleMap.setPadding(0, getStatusBarHeight(mapView), 0, 0); googleMap.getUiSettings().setMapToolbarEnabled(false); googleMap.addMarker(new MarkerOptions().position(location)); googleMap.moveCamera(CameraUpdateFactory.zoomTo(DEFAULT_ZOOM_LEVEL)); googleMap.moveCamera(CameraUpdateFactory.newLatLng(location)); }
Example 3
Source File: GeoPointMapActivity.java From commcare-android with Apache License 2.0 | 6 votes |
@Override public void onMapReady(GoogleMap map) { this.map = map; if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { map.getUiSettings().setMyLocationButtonEnabled(true); map.setMyLocationEnabled(true); map.setOnMyLocationButtonClickListener(this); } MapsInitializer.initialize(this); if (location.hasAccuracy()) { drawMarker(); } setupMapListeners(); map.setMapType(HiddenPreferences.getMapsDefaultLayer().getValue()); }
Example 4
Source File: PlacePickerActivity.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private void enableMyLocationButtonIfHaveThePermission(GoogleMap googleMap) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { googleMap.setMyLocationEnabled(true); } }
Example 5
Source File: LocationSourceActivity.java From Complete-Google-Map-API-Tutorial with Apache License 2.0 | 5 votes |
@Override public void onMapReady(GoogleMap map) { googleMap = map; googleMap.setOnMapLongClickListener(this); if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { enableMyLocation(); } else { map.setMyLocationEnabled(true); } }
Example 6
Source File: FenceRecyclerAdapter.java From JCVD with MIT License | 5 votes |
@Override public void onMapReady(GoogleMap googleMap) { googleMap.setMyLocationEnabled(true); googleMap.getUiSettings().setMyLocationButtonEnabled(false); StorableLocationFence locFence = null; if (!mFence.getAndFences().isEmpty()) { for (StorableFence andFence : mFence.getAndFences()) { if (andFence.getType().equals(StorableFence.Type.LOCATION)) { locFence = (StorableLocationFence) andFence; } } } else { if (mFence.getType().equals(StorableFence.Type.LOCATION)) { locFence = (StorableLocationFence) mFence; } } if (locFence != null) { LatLng latLng = new LatLng(locFence.getLatitude(), locFence.getLongitude()); CircleOptions circleOptions = new CircleOptions() .center(latLng) .radius(locFence.getRadius()); // In meters googleMap.addCircle(circleOptions); CameraPosition cameraPosition = new CameraPosition.Builder() .target(latLng) .zoom(14) .build(); googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); } }
Example 7
Source File: Maps.java From aware with MIT License | 5 votes |
@Override public void onMapReady(GoogleMap map) { map.setMapType(GoogleMap.MAP_TYPE_NORMAL); map.setMyLocationEnabled(true); map.setTrafficEnabled(false); map.setIndoorEnabled(false); map.setBuildingsEnabled(false); map.getUiSettings().setZoomControlsEnabled(true); final CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(21, 78)); CameraUpdate zoom = CameraUpdateFactory.zoomTo(15); map.moveCamera(center); map.animateCamera(zoom); GPSTracker tracker = new GPSTracker(activity); if (!tracker.canGetLocation()) { tracker.showSettingsAlert(); } else { latitude = tracker.getLatitude(); longitude = tracker.getLongitude(); LatLng coordinate = new LatLng(latitude, longitude); CameraUpdate yourLocation = CameraUpdateFactory.newLatLngZoom(coordinate, 5); map.animateCamera(yourLocation); } this.map = map; }
Example 8
Source File: MapUiHandler.java From overpasser with Apache License 2.0 | 5 votes |
void setMapParams() { GoogleMap googleMap = fragment.getGoogleMap(); googleMap.setMapType(MAP_TYPE_NORMAL); googleMap.setMyLocationEnabled(true); googleMap.setInfoWindowAdapter(poiInfoWindowAdapter); googleMap.getUiSettings().setMapToolbarEnabled(false); googleMap.setOnCameraChangeListener(getOnCameraChangeListener()); resetMap(); }
Example 9
Source File: PPTGoogleMapManager.java From react-native-maps with MIT License | 4 votes |
/** * Event handler for when map is ready to receive update parameters. * * @param googleMap */ @Override public void onMapReady(GoogleMap googleMap) { // Clear previous map if already there googleMap.clear(); UiSettings settings = googleMap.getUiSettings(); // Set location based flags if (locationManager != null) { settings.setMyLocationButtonEnabled(this.myLocationButton); googleMap.setMyLocationEnabled(this.showsUserLocation); } // Set all other flags settings.setScrollGesturesEnabled(this.scrollGestures); settings.setZoomGesturesEnabled(this.zoomGestures); settings.setTiltGesturesEnabled(this.tiltGestures); settings.setRotateGesturesEnabled(this.rotateGestures); settings.setCompassEnabled(this.compassButton); // Update the camera position if (cameraUpdate != null) { googleMap.moveCamera(cameraUpdate); } // Add the markers addMapMarkers(googleMap); googleMap.setOnMarkerClickListener(this); // Attach the event handlers if (firstMapReady) { googleMap.setOnCameraChangeListener(this); googleMap.setOnMapClickListener(this); googleMap.setOnMapLongClickListener(this); googleMap.setOnMarkerDragListener(this); googleMap.setOnMyLocationButtonClickListener(this); firstMapReady = false; } }
Example 10
Source File: MapActivity.java From Forage with Mozilla Public License 2.0 | 4 votes |
@SuppressLint("MissingPermission") private void enableMapLocation(GoogleMap googleMap) { googleMap.setMyLocationEnabled(true); presenter.centerMapOnLocation(); }
Example 11
Source File: LocationSourceDemoActivity.java From android-samples with Apache License 2.0 | 4 votes |
@Override public void onMapReady(GoogleMap map) { map.setLocationSource(mLocationSource); map.setOnMapLongClickListener(mLocationSource); map.setMyLocationEnabled(true); }
Example 12
Source File: MainActivity.java From ExamplesAndroid with Apache License 2.0 | 3 votes |
@Override public void onMapReady(GoogleMap googleMap) { googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); // Habilitamos la opcion de localizacion googleMap.setMyLocationEnabled(true); googleMap.getUiSettings().setZoomControlsEnabled(true); }