Java Code Examples for com.google.android.gms.maps.GoogleMap#setMapType()

The following examples show how to use com.google.android.gms.maps.GoogleMap#setMapType() . 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 vote down vote up
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: GglMap.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void switchMapStyle(int mapStyle) {
    if (!this.isInit) {
        return;
    }
    GoogleMap googleMap;
    GoogleMap googleMap2;
    if (mapStyle == Constants.X8_GENERAL_MAP_STYLE_NORMAL) {
        googleMap = this.googleMap;
        googleMap2 = this.googleMap;
        googleMap.setMapType(1);
    } else if (mapStyle == Constants.X8_GENERAL_MAP_STYLE_SATELLITE) {
        googleMap = this.googleMap;
        googleMap2 = this.googleMap;
        googleMap.setMapType(2);
    }
}
 
Example 3
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 4
Source File: MainActivity.java    From ExamplesAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    // Add a marker in Sydney, Australia, and move the camera.

    LatLng lugar = new LatLng(19.4112431, -99.2091994);//creamos una #localizacion#
    googleMap.addMarker(new MarkerOptions().position(lugar).title("Saludos desde Mexico"));//creamos una marca en el mapa "lugar"
    googleMap.moveCamera(CameraUpdateFactory.newLatLng(lugar));//Movemos la camara en la localizacion "lugar" asignado

    //Formas de visualizar un mapa
    // MAP_TYPE_TERRAIN, MAP_TYPE_HYBRID y  MAP_TYPE_NONE

    // googleMap.setMapType(GoogleMap.MAP_TYPE_NONE);//Vista sin mapa
    //googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);//Vista Normal
    googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);//Vista Satelital
    //googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);//Vista Terreno
    //googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);//Vista Hibrida
}
 
Example 5
Source File: GeoPointMapActivity.java    From commcare-android with Apache License 2.0 6 votes vote down vote up
@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 6
Source File: DetailFragment.java    From animation-samples with Apache License 2.0 5 votes vote down vote up
@NonNull
private GoogleMap.OnMapLoadedCallback getOnMapLoadedCallback(final GoogleMap googleMap) {
    return new GoogleMap.OnMapLoadedCallback() {
        @Override
        public void onMapLoaded() {
            googleMap.getUiSettings().setMapToolbarEnabled(false);
            if (mGallery.hasDetails()) {
                googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
                googleMap.animateCamera(
                        CameraUpdateFactory.newLatLngBounds(mGallery.getBounds(), mMapPadding));
            }
        }
    };
}
 
Example 7
Source File: Maps.java    From aware with MIT License 5 votes vote down vote up
@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: GoogleMapUtis.java    From Airbnb-Android-Google-Map-View with MIT License 5 votes vote down vote up
public static void toggleStyle(GoogleMap googleMap) {
	if (GoogleMap.MAP_TYPE_NORMAL == googleMap.getMapType()) {
		googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);		
	} else {
		googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
	}
}
 
Example 9
Source File: GridAdapter.java    From snazzymaps-browser with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the map for each grid item by showing it, applying the given style, and
 * setting up the click handler.
 *
 * @param map
 * @param style
 */
private void initializeMap(GoogleMap map, final SnazzyMapsStyle style) {
    style.applyToMap(map);
    map.moveCamera(CameraUpdateFactory.newLatLngZoom(MapActivity.START_LATLNG, 10));
    map.getUiSettings().setMapToolbarEnabled(false);  // Removes the map button.
    map.setMapType(GoogleMap.MAP_TYPE_NORMAL);  // Shows the map.
    map.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
        @Override
        public void onMapClick(LatLng latLng) {
            ((OnGridItemClickHandler) mContext).onGridItemClick(style);
        }
    });
}
 
Example 10
Source File: MainActivity.java    From PokeFaker with MIT License 5 votes vote down vote up
private void setMap(GoogleMap map) {
    float density = getResources().getDisplayMetrics().density;
    map.setPadding(0, ((int) (82* density)), 0, 0);
    map.setOnMapClickListener(this);
    map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker marker) {
            return true;
        }
    });
}
 
Example 11
Source File: MapUiHandler.java    From overpasser with Apache License 2.0 5 votes vote down vote up
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 12
Source File: GalleryAdapter.java    From animation-samples with Apache License 2.0 4 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    googleMap.setMapType(GoogleMap.MAP_TYPE_NONE);
    googleMap.getUiSettings().setMapToolbarEnabled(false);
}
 
Example 13
Source File: ProfileActivity.java    From mage-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onMapReady(GoogleMap map) {
	SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
	map.setMapType(preferences.getInt(getString(R.string.baseLayerKey), getResources().getInteger(R.integer.baseLayerDefaultValue)));

	int dayNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
	if (dayNightMode == Configuration.UI_MODE_NIGHT_NO) {
		map.setMapStyle(null);
	} else {
		map.setMapStyle(MapStyleOptions.loadRawResourceStyle(getApplicationContext(), R.raw.map_theme_night));
	}


	if (latLng != null && icon != null) {
		map.addMarker(new MarkerOptions()
			.position(latLng)
			.icon(icon));

		LocationProperty accuracyProperty = location.getPropertiesMap().get("accuracy");
		if (accuracyProperty != null) {
			float accuracy = Float.parseFloat(accuracyProperty.getValue().toString());

			int color = LocationBitmapFactory.locationColor(getApplicationContext(), location);
			map.addCircle(new CircleOptions()
				.center(latLng)
				.radius(accuracy)
				.fillColor(ColorUtils.setAlphaComponent(color, (int) (256 * .20)))
				.strokeColor(ColorUtils.setAlphaComponent(color, (int) (256 * .87)))
				.strokeWidth(2.0f));

			double latitudePadding = (accuracy / 111325);
			LatLngBounds bounds = new LatLngBounds(
					new LatLng(latLng.latitude - latitudePadding, latLng.longitude),
					new LatLng(latLng.latitude + latitudePadding, latLng.longitude));

			int minDimension = Math.min(mapView.getWidth(), mapView.getHeight());
			int padding = (int) Math.floor(minDimension / 5f);
			map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding));
		} else {
			map.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 17));
		}
	}
}
 
Example 14
Source File: MainActivity.java    From ExamplesAndroid with Apache License 2.0 3 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {

    googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);

    // Habilitamos la opcion de localizacion
    googleMap.setMyLocationEnabled(true);


    googleMap.getUiSettings().setZoomControlsEnabled(true);



}