Java Code Examples for com.google.android.gms.maps.UiSettings#setMyLocationButtonEnabled()
The following examples show how to use
com.google.android.gms.maps.UiSettings#setMyLocationButtonEnabled() .
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: GoogleMapsMapAdapter.java From ground-android with Apache License 2.0 | 6 votes |
public GoogleMapsMapAdapter(GoogleMap map, Context context, MarkerIconFactory markerIconFactory) { this.map = map; this.context = context; this.markerIconFactory = markerIconFactory; map.setMapType(GoogleMap.MAP_TYPE_HYBRID); UiSettings uiSettings = map.getUiSettings(); uiSettings.setRotateGesturesEnabled(false); uiSettings.setTiltGesturesEnabled(false); uiSettings.setMyLocationButtonEnabled(false); uiSettings.setMapToolbarEnabled(false); uiSettings.setCompassEnabled(false); uiSettings.setIndoorLevelPickerEnabled(false); map.setOnMarkerClickListener(this::onMarkerClick); map.setOnCameraIdleListener(this::onCameraIdle); map.setOnCameraMoveStartedListener(this::onCameraMoveStarted); map.setOnCameraMoveListener(this::onCameraMove); onCameraMove(); }
Example 2
Source File: MapSettingsActivity.java From Complete-Google-Map-API-Tutorial with Apache License 2.0 | 5 votes |
@Override public void onMapReady(GoogleMap map) { googleMap = map; UiSettings uiSettings = googleMap.getUiSettings(); enableMyLocation(); googleMap.setIndoorEnabled(true); googleMap.setBuildingsEnabled(true); googleMap.setTrafficEnabled(true); uiSettings.setCompassEnabled(true); uiSettings.setMyLocationButtonEnabled(true); uiSettings.setZoomControlsEnabled(true); uiSettings.setMapToolbarEnabled(true); uiSettings.setIndoorLevelPickerEnabled(true); uiSettings.setRotateGesturesEnabled(true); uiSettings.setScrollGesturesEnabled(true); uiSettings.setTiltGesturesEnabled(true); uiSettings.setZoomGesturesEnabled(true); uiSettings.setAllGesturesEnabled(true); googleMap.addMarker(new MarkerOptions().position(MADISON_SQUARE_GARDEN)); googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(MADISON_SQUARE_GARDEN, 17)); }
Example 3
Source File: MapActivity.java From homeassist with Apache License 2.0 | 4 votes |
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.setOnMarkerClickListener(this); UiSettings uiSettings = mMap.getUiSettings(); uiSettings.setCompassEnabled(true); uiSettings.setZoomControlsEnabled(true); uiSettings.setMyLocationButtonEnabled(true); uiSettings.setAllGesturesEnabled(true); uiSettings.setMyLocationButtonEnabled(true); DatabaseManager databaseManager = DatabaseManager.getInstance(this); ArrayList<Entity> devices = databaseManager.getDeviceLocations(); LatLngBounds.Builder builder = new LatLngBounds.Builder(); int zoneCount = 0; int deviceCount = 0; for (Entity device : devices) { Log.d("YouQi", "Device: " + CommonUtil.deflate(device)); LatLng latLng = device.getLocation(); if (latLng == null) continue; builder.include(latLng); if (device.isZone()) { zoneCount += 1; Log.d("YouQi", "Zone!!"); Circle circle = mMap.addCircle(new CircleOptions() .center(latLng) // .strokeColor(Color.RED) .strokeColor(Color.parseColor("#FF5722")) .fillColor(Color.parseColor("#33FFAB91"))); if (device.attributes.radius != null) { circle.setRadius(device.attributes.radius.floatValue()); } if (device.hasMdiIcon()) { Log.d("YouQi", "hasMdiIcon"); mMap.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromBitmap(mifZoneIcon.makeMaterialIcon(device.getMdiIcon()))) .position(latLng) .zIndex(1.0f) .anchor(mifZoneIcon.getAnchorU(), mifZoneIcon.getAnchorV())); } else { Log.d("YouQi", "nope"); mMap.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromBitmap(mifZoneText.makeIcon(device.getFriendlyName()))) .position(latLng) .zIndex(1.0f) .anchor(mifZoneText.getAnchorU(), mifZoneText.getAnchorV())); } } else if (device.isDeviceTracker()) { deviceCount += 1; Marker marker = createMarker(device); markers.put(device.entityId, marker); } } if (deviceCount == 0 && zoneCount == 0) { mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.3333395, -30.3274332), 2)); new MaterialDialog.Builder(this) .cancelable(false) .title(R.string.title_nozone) .content(R.string.content_nozone) .positiveText(R.string.button_continue) .positiveColorRes(R.color.md_red_500) .buttonRippleColorRes(R.color.md_grey_200) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); } }) .show(); } else { LatLngBounds bounds = builder.build(); int width = getResources().getDisplayMetrics().widthPixels; int height = getResources().getDisplayMetrics().heightPixels; int padding = (int) (width * 0.20); // offset from edges of the map 10% of screen CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, width, height, padding); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(bounds.getCenter(), 10)); mMap.animateCamera(cu); } //mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); }
Example 4
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 5
Source File: CampusMapActivity.java From utexas-utilities with Apache License 2.0 | 4 votes |
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.setMyLocationEnabled(locationEnabled); MarkerManager markerManager = new MarkerManager(mMap); shownBuildings = markerManager.newCollection(); shownStops = markerManager.newCollection(); UiSettings ui = mMap.getUiSettings(); ui.setMyLocationButtonEnabled(true); ui.setZoomControlsEnabled(true); ui.setAllGesturesEnabled(true); ui.setCompassEnabled(true); Intent testPackage = new Intent(); testPackage.setPackage("com.google.android.apps.maps"); ui.setMapToolbarEnabled(testPackage.resolveActivity(getPackageManager()) != null); shownStops.setOnInfoWindowAdapter(new StopInfoWindowAdapter()); shownBuildings.setOnInfoWindowAdapter(new MyInfoWindowAdapter()); mMap.setOnInfoWindowClickListener(new InfoClickListener()); mMap.setInfoWindowAdapter(markerManager); loadRoute(routeid); if (buildingIdList.size() > 0) { loadBuildingOverlay(false, false); } mapView = getSupportFragmentManager().findFragmentById(R.id.map).getView(); if (mapView != null && mapView.getViewTreeObserver() != null && mapView.getViewTreeObserver().isAlive()) { mapView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressLint("NewApi") @SuppressWarnings("deprecation") @Override public void onGlobalLayout() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { mapView.getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { mapView.getViewTreeObserver().removeOnGlobalLayoutListener(this); } if (mSetCameraToBounds) { mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(llbuilder.build(), 100)); mSetCameraToBounds = false; setInitialLocation = true; } } }); } // If location is enabled, then we want the GoogleApiClient to handle moving to the // initial location. Otherwise, we might not have a location by the time this is called if (!locationEnabled) { moveToInitialLoc(locationEnabled); } handleIntent(getIntent()); }