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

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

}