Java Code Examples for com.google.android.gms.maps.UiSettings#setZoomControlsEnabled()

The following examples show how to use com.google.android.gms.maps.UiSettings#setZoomControlsEnabled() . 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: 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 2
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 3
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 4
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 5
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());

}