com.google.android.gms.maps.UiSettings Java Examples

The following examples show how to use com.google.android.gms.maps.UiSettings. 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 vote down vote up
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: MapActivity.java    From WechatHook-Dusan with Apache License 2.0 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    this.googlemap = googleMap;
    if (googlemap != null) {
        googlemap.setOnCameraMoveListener(this);
    }
    addGoogleMarker();
    googlemap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
        @Override
        public void onMapClick(com.google.android.gms.maps.model.LatLng latLng) {
            longitude = latLng.longitude;
            latitude = latLng.latitude;
            getGooglePosition(latLng);
        }
    });
    UiSettings uiSettings = googlemap.getUiSettings();
    uiSettings.setAllGesturesEnabled(true);
    uiSettings.setMapToolbarEnabled(true);
    uiSettings.setZoomControlsEnabled(true);
    //uiSettings.setCompassEnabled(true);
}
 
Example #3
Source File: MainActivity.java    From live-app-android with MIT License 6 votes vote down vote up
public void getMapAsync(@NonNull final OnMapReadyCallback onMapReadyCallback) {
    if (mMap == null) {
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(GoogleMap googleMap) {
                mMap = googleMap;
                UiSettings uiSettings = googleMap.getUiSettings();
                uiSettings.setMapToolbarEnabled(false);

                onMapReadyCallback.onMapReady(googleMap);
            }
        });
    } else {
        onMapReadyCallback.onMapReady(mMap);
    }

}
 
Example #4
Source File: MapFragment.java    From droidkaigi2016 with Apache License 2.0 6 votes vote down vote up
@NeedsPermission(Manifest.permission.ACCESS_FINE_LOCATION)
void initGoogleMap() {
    SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);

    mapFragment.getMapAsync(googleMap -> {
        //noinspection MissingPermission
        googleMap.setMyLocationEnabled(true);
        binding.mapSearchView.bindData(placeMapList, placeMap -> {
            LatLng latLng = new LatLng(placeMap.latitude, placeMap.longitude);
            int duration = getResources().getInteger(R.integer.map_camera_move_mills);
            googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng), duration, null);
            Marker marker = markers.get(placeMap.nameRes);
            if (marker != null) marker.showInfoWindow();
        });

        binding.loadingView.setVisibility(View.GONE);
        googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        googleMap.setIndoorEnabled(true);
        googleMap.setBuildingsEnabled(true);
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LAT_LNG_CENTER, DEFAULT_ZOOM));
        UiSettings mapUiSettings = googleMap.getUiSettings();
        mapUiSettings.setCompassEnabled(true);
        renderMarkers(placeMapList, googleMap);
    });
}
 
Example #5
Source File: NativeGoogleMapFragment.java    From AirMapView with Apache License 2.0 6 votes vote down vote up
public void init() {
  getMapAsync(new OnMapReadyCallback() {
    @Override public void onMapReady(GoogleMap googleMap) {
      if (googleMap != null && getActivity() != null) {
        NativeGoogleMapFragment.this.googleMap = googleMap;
        UiSettings settings = NativeGoogleMapFragment.this.googleMap.getUiSettings();
        settings.setZoomControlsEnabled(false);
        settings.setMyLocationButtonEnabled(false);
        setMyLocationEnabled(myLocationEnabled);

        if (onMapLoadedListener != null) {
          onMapLoadedListener.onMapLoaded();
        }
      }
    }
  });
}
 
Example #6
Source File: MapFragment.java    From droidkaigi2016 with Apache License 2.0 6 votes vote down vote up
@NeedsPermission(Manifest.permission.ACCESS_FINE_LOCATION)
void initGoogleMap() {
    SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);

    mapFragment.getMapAsync(googleMap -> {
        //noinspection MissingPermission
        googleMap.setMyLocationEnabled(true);
        binding.mapSearchView.bindData(placeMapList, placeMap -> {
            LatLng latLng = new LatLng(placeMap.latitude, placeMap.longitude);
            int duration = getResources().getInteger(R.integer.map_camera_move_mills);
            googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng), duration, null);
            Marker marker = markers.get(placeMap.nameRes);
            if (marker != null) marker.showInfoWindow();
        });

        binding.loadingView.setVisibility(View.GONE);
        googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        googleMap.setIndoorEnabled(true);
        googleMap.setBuildingsEnabled(true);
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LAT_LNG_CENTER, DEFAULT_ZOOM));
        UiSettings mapUiSettings = googleMap.getUiSettings();
        mapUiSettings.setCompassEnabled(true);
        renderMarkers(placeMapList, googleMap);
    });
}
 
Example #7
Source File: SampleActivity.java    From clusterkraf with Apache License 2.0 6 votes vote down vote up
private void initMap() {
	if (map == null) {
		SupportMapFragment mapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
		if (mapFragment != null) {
			map = mapFragment.getMap();
			if (map != null) {
				UiSettings uiSettings = map.getUiSettings();
				uiSettings.setAllGesturesEnabled(false);
				uiSettings.setScrollGesturesEnabled(true);
				uiSettings.setZoomGesturesEnabled(true);
				map.setOnCameraChangeListener(new OnCameraChangeListener() {
					@Override
					public void onCameraChange(CameraPosition arg0) {
						moveMapCameraToBoundsAndInitClusterkraf();
					}
				});
			}
		}
	} else {
		moveMapCameraToBoundsAndInitClusterkraf();
	}
}
 
Example #8
Source File: MapSettingsActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 5 votes vote down vote up
@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 #9
Source File: MapActivity.java    From homeassist with Apache License 2.0 4 votes vote down vote up
@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 #10
Source File: PPTGoogleMapManager.java    From react-native-maps with MIT License 4 votes vote down vote up
/**
 * 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 #11
Source File: TagsDemoActivity.java    From android-samples with Apache License 2.0 4 votes vote down vote up
@Override
public void onMapReady(GoogleMap map) {
    mMap = map;

    UiSettings mUiSettings = mMap.getUiSettings();

    // Turn off the map toolbar.
    mUiSettings.setMapToolbarEnabled(false);

    // Disable interaction with the map - other than clicking.
    mUiSettings.setZoomControlsEnabled(false);
    mUiSettings.setScrollGesturesEnabled(false);
    mUiSettings.setZoomGesturesEnabled(false);
    mUiSettings.setTiltGesturesEnabled(false);
    mUiSettings.setRotateGesturesEnabled(false);

    // Add a circle, a ground overlay, a marker, a polygon and a polyline to the map.
    addObjectsToMap();

    // Set listeners for click events.  See the bottom of this class for their behavior.
    mMap.setOnCircleClickListener(this);
    mMap.setOnGroundOverlayClickListener(this);
    mMap.setOnMarkerClickListener(this);
    mMap.setOnPolygonClickListener(this);
    mMap.setOnPolylineClickListener(this);

    // Override the default content description on the view, for accessibility mode.
    // Ideally this string would be localised.
    map.setContentDescription(getString(R.string.tags_demo_map_description));

    // Create bounds that include all locations of the map.
    LatLngBounds bounds = new LatLngBounds.Builder()
            .include(ADELAIDE)
            .include(BRISBANE)
            .include(DARWIN)
            .include(HOBART)
            .include(PERTH)
            .include(SYDNEY)
            .build();
    mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100));
}
 
Example #12
Source File: CampusMapActivity.java    From utexas-utilities with Apache License 2.0 4 votes vote down vote up
@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());

}
 
Example #13
Source File: UiSettingsAssert.java    From assertj-android with Apache License 2.0 4 votes vote down vote up
public UiSettingsAssert(UiSettings actual) {
  super(actual, UiSettingsAssert.class);
}