com.google.android.gms.maps.model.MapStyleOptions Java Examples

The following examples show how to use com.google.android.gms.maps.model.MapStyleOptions. 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: MapTypeAndStyleActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 6 votes vote down vote up
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l)
{
	if (adapterView.getId() == R.id.sMapType)
	{
		googleMap.setMapType(mapTypes[i]);
	} else if (adapterView.getId() == R.id.sMapStyle)
	{
		try
		{
			googleMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(this, mapStyles[i]));
		} catch (Exception exc)
		{
			googleMap.setMapStyle(null);
		}
	}
}
 
Example #2
Source File: Home.java    From UberClone with MIT License 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    mMap.getUiSettings().setZoomControlsEnabled(true);
    mMap.getUiSettings().setZoomGesturesEnabled(true);
    mMap.setInfoWindowAdapter(new CustomInfoWindow(this));
    googleMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(this, R.raw.uber_style_map));

    mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
        @Override
        public void onMapClick(LatLng latLng) {
            if(destinationMarker!=null)
                destinationMarker.remove();
            destinationMarker=mMap.addMarker(new MarkerOptions().position(latLng)
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_destination_marker))
                    .title("Destination"));
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15.0f));

            BottomSheetRiderFragment mBottomSheet=BottomSheetRiderFragment.newInstance(String.format("%f,%f", currentLat, currentLng),
                    String.format("%f,%f",latLng.latitude, latLng.longitude), true);
            mBottomSheet.show(getSupportFragmentManager(), mBottomSheet.getTag());
        }
    });
    mMap.setOnInfoWindowClickListener(this);
}
 
Example #3
Source File: Home.java    From Taxi-App-Android-XML with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    boolean success = googleMap.setMapStyle(new MapStyleOptions(getResources()
            .getString(R.string.style_json)));

    if (!success) {
        Log.e("Style", "Style parsing failed.");
    }
    LatLng jakarta = new LatLng(-6.232812, 106.820933);
    LatLng southjakarta = new LatLng(-6.22865,106.8151753);
    mMap.addMarker(new MarkerOptions().position(jakarta).icon(BitmapDescriptorFactory.fromBitmap(getBitmapFromView("Set Pickup Location", R.drawable.dot_pickup))));
    mMap.addMarker(new MarkerOptions().position(southjakarta).icon(BitmapDescriptorFactory.fromBitmap(getBitmapFromView("Set Dropoff Location", R.drawable.dot_dropoff))));
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(jakarta, 15f));


}
 
Example #4
Source File: BaseNiboFragment.java    From Nibo with MIT License 6 votes vote down vote up
protected MapStyleOptions getMapStyle() {
    if (mStyleEnum == NiboStyle.CUSTOM) {
        if (mStyleFileID != DEFAULT_MARKER_ICON_RES) {
            return MapStyleOptions.loadRawResourceStyle(
                    getActivity(), mStyleFileID);
        } else {
            throw new IllegalStateException("NiboStyle.CUSTOM requires that you supply a custom style file, you can get one at https://snazzymaps.com/explore");
        }
    } else if (mStyleEnum == NiboStyle.DEFAULT) {
        return null;
    } else {
        if (mStyleEnum == null) {
            return null;
        }
        {
            return MapStyleOptions.loadRawResourceStyle(
                    getActivity(), mStyleEnum.getValue());
        }
    }
}
 
Example #5
Source File: MapsActivity.java    From journaldev with MIT License 6 votes vote down vote up
private void setMapStyle() {


        if (currentIndex == rawArray.length && rawArray.length != 0) {
            currentIndex = 0;
        }

        try {
            mMap.setMapStyle(
                    MapStyleOptions.loadRawResourceStyle(
                            this, rawArray[currentIndex++]));

        } catch (Resources.NotFoundException e) {
            Log.e("MapsActivity", "Cannot find style.", e);
        }
    }
 
Example #6
Source File: DriverHome.java    From UberClone with MIT License 5 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    mMap.setTrafficEnabled(false);
    mMap.setIndoorEnabled(false);
    mMap.setBuildingsEnabled(false);
    mMap.getUiSettings().setZoomControlsEnabled(true);
    googleMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(this, R.raw.uber_style_map));
}
 
Example #7
Source File: TripDetail.java    From UberClone with MIT License 5 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    googleMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(this, R.raw.uber_style_map));
    settingInformation();
}
 
Example #8
Source File: MyTrip.java    From Taxi-App-Android-XML with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    boolean success = googleMap.setMapStyle(new MapStyleOptions(getResources()
            .getString(R.string.style_json)));

    if (!success) {
        Log.e("Style", "Style parsing failed.");
    }
    LatLng jakarta = new LatLng(-6.232812, 106.820933);
    mMap.addMarker(new MarkerOptions().position(jakarta).icon(BitmapDescriptorFactory.fromBitmap(getBitmapFromView("Set Pickup Location", R.drawable.dot_pickup))));
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(jakarta, 15f));
}
 
Example #9
Source File: GoogleMapStyler.java    From ThemedGoogleMap with Apache License 2.0 5 votes vote down vote up
/**
 * Call this method to build the GoogleMapStyler
 *
 * @return GoogleMapStyler
 */
public GoogleMapStyler build() {
    if (json.length() > 1) {
        json = json.deleteCharAt(json.length() - 1);
    }
    json = json.append("]");
    String temp = json.toString().replaceAll("\\\\", "");
    googleMapStyler.setMapStyleOptions(new MapStyleOptions(temp));
    return googleMapStyler;
}
 
Example #10
Source File: EstablishmentPresenterImpl.java    From Saude-no-Mapa with MIT License 5 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(mContext, R.raw.map_style);
    mMap.setMapStyle(style);
    checkPermissions();
    configureMapClickListener();
}
 
Example #11
Source File: EmergencyPresenterImpl.java    From Saude-no-Mapa with MIT License 5 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(mContext, R.raw.map_style);
    mMap.setMapStyle(style);
    checkPermissions();
    configureMapClickListener();
}
 
Example #12
Source File: SnazzyMapsStyle.java    From snazzymaps-browser with Apache License 2.0 5 votes vote down vote up
/**
 * Shortcut for applying this style to a {@link GoogleMap}.
 *
 * @param map The {@link GoogleMap} object to style.
 */
void applyToMap(GoogleMap map) {
    try {
        map.setMapStyle(new MapStyleOptions(mJson.getString("json")));
    } catch (JSONException e) {
        Log.e(TAG, e.toString());
    }
}
 
Example #13
Source File: MapsActivity.java    From journaldev with MIT License 4 votes vote down vote up
/**
 * Manipulates the map once available.
 * This callback is triggered when the map is ready to be used.
 * This is where we can add markers or lines, add listeners or move the camera. In this case,
 * we just add a marker near Sydney, Australia.
 * If Google Play services is not installed on the device, the user will be prompted to install
 * it inside the SupportMapFragment. This method will only be triggered once the user has
 * installed Google Play services and returned to the app.
 */
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    // Add a marker in Sydney and move the camera
    /*LatLng sydney = new LatLng(-34, 151);
    mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));*/

    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }
    mMap.setMyLocationEnabled(true);
    mMap.setTrafficEnabled(true);
    mMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_night));

    /**
     * UNCOMMENT TO TEST setLatLngBoundsForCameraTarget
     *
     *
     * final LatLngBounds ADELAIDE = new LatLngBounds(
            new LatLng(-35.0, 138.58), new LatLng(-34.9, 138.61));
    final CameraPosition ADELAIDE_CAMERA = new CameraPosition.Builder()
            .target(new LatLng(-34.92873, 138.59995)).zoom(20.0f).bearing(0).tilt(0).build();

    mMap.setLatLngBoundsForCameraTarget(ADELAIDE);

    mMap.addMarker(new MarkerOptions()
            .position(new LatLng(-34.92873, 138.59995))
            .title("My Marker"));


    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(ADELAIDE_CAMERA));

     **
     */

}
 
Example #14
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 #15
Source File: GoogleMapStyler.java    From ThemedGoogleMap with Apache License 2.0 2 votes vote down vote up
/**
 * Method returns the generated MapStyleOptions object to set to the google map.
 *
 * @return mapStyleOptions google map style options
 */
public MapStyleOptions getMapStyleOptions() {
    return mapStyleOptions;
}
 
Example #16
Source File: GoogleMapStyler.java    From ThemedGoogleMap with Apache License 2.0 2 votes vote down vote up
/**
 * Method sets the MapStyleOptions object
 *
 * @param mapStyleOptions google map style options
 */
private void setMapStyleOptions(MapStyleOptions mapStyleOptions) {
    this.mapStyleOptions = mapStyleOptions;
}