/** * Manipulates the map when it's available. * The API invokes this callback when the map is ready for use. */ @Override public void onMapReady(GoogleMap googleMap) { try { // Customise the styling of the base map using a JSON object defined // in a raw resource file. boolean success = googleMap.setMapStyle( MapStyleOptions.loadRawResourceStyle( this, R.raw.style_json)); if (!success) { Log.e(TAG, "Style parsing failed."); } } catch (Resources.NotFoundException e) { Log.e(TAG, "Can't find style. Error: ", e); } // Position the map's camera near Sydney, Australia. googleMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(-34, 151))); } }
/** * 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; mMap.setMaxZoomPreference(20); MapStyleOptions style = MapStyleOptions.loadRawResourceStyle( this, R.raw.maps_style); googleMap.setMapStyle(style); if (checkPermission()) onLocationPermissionGranted(); }
return; mMap.setMapStyle(style);
@Override public boolean setMapStyle(MapStyleOptions mapStyleOptions) { return map.setMapStyle(mapStyleOptions); }
public void setCustomMapStyle(int mapstyle) { if (googleMap != null) try { boolean success = googleMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(mContext, mapstyle)); if (!success) { Log.e("mLocation ", "detail activity,Style parsing failed."); } } catch (Resources.NotFoundException e) { Log.e("mLocation ", "detail activity, Can't find style. Error: " + e); } }
/** * Loads a style from the map_style.json file to style the Google Map. Log * the errors if the loading fails. * * @param map The GoogleMap object to style. */ private void setMapStyle(GoogleMap map) { try { // Customise the styling of the base map using a JSON object defined // in a raw resource file. boolean success = map.setMapStyle( MapStyleOptions.loadRawResourceStyle( this, R.raw.map_style)); if (!success) { Log.e(TAG, "Style parsing failed."); } } catch (Resources.NotFoundException e) { Log.e(TAG, "Can't find style. Error: ", e); } }
@Override public void onMapReady(GoogleMap googleMap) { MapsInitializer.initialize(context); MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(context, R.raw.mapstyle_night); map = googleMap; map.setMapStyle(style); final ViewOption viewOption = (ViewOption) mapView.getTag(); if (viewOption != null) { setMapLocation(viewOption, map, context); } }
private static void setSelectedStyle(StyleDef styleName, GoogleMap googleMap, Context context) { MapStyleOptions style; switch (styleName) { case RETRO: style = MapStyleOptions.loadRawResourceStyle(context, R.raw.mapstyle_retro); break; case NIGHT: style = MapStyleOptions.loadRawResourceStyle(context, R.raw.mapstyle_night); break; case GRAY_SCALE: style = MapStyleOptions.loadRawResourceStyle(context, R.raw.mapstyle_grayscale); break; case DEFAULT: style = null; break; default: return; } googleMap.setMapStyle(style); }
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.getUiSettings().setMyLocationButtonEnabled(false); mMap.setMaxZoomPreference(20); if (getMapStyle() != null) { googleMap.setMapStyle(getMapStyle()); } }
@Override public void onMapReady(GoogleMap googleMap) { GoogleMapStyler googleMapStyler = new GoogleMapStyler.Builder(MainActivity.this) .setMainGeometryColorRes(R.color.maingeometrycolor) .setAllPlaceTextStrokeAlpha(-80) .setAllPlaceTextColorRes(R.color.adminstartivelabel) .setAllMainTownTextColorRes(R.color.administativelocality) .setAllPoiTextColorRes(R.color.poitext) .setAllPoiParkBackgroundColorRes(R.color.poiparkbackground) .setAllPoiParkTextColorRes(R.color.poilabel) .setAllRoadBackgroundColorRes(R.color.roadbackground) .setAllRoadTextColorRes(R.color.roadlabel) .setAllRoadArterialBackgroundColorRes(R.color.roadarterialbackground) .setAllRoadArterialStrokeColorRes(R.color.roadarterialstroke) .setAllRoadHighwayBackgroundColorRes(R.color.roadhighway) .setAllRoadHighwayStrokeColorRes(R.color.roadhighwaystroke) .setAllRoadHighwayTextColorRes(R.color.roadhighwaylabel) .setAllRoadLocalBackgroundColorRes(R.color.roadlocal) .setAllRoadLocalStrokeColorRes(R.color.roadlocalstroke) .setAllTransitStationTextColorRes(R.color.transitstationtext) .setAllTransitBackgroundColorRes(R.color.transit) .setAllWaterTextColorRes(R.color.waterlabel) .setAllWaterBackgroundColorRes(R.color.water) .setAllWaterTextStrokeAlpha(-20) .build(); boolean success = googleMap.setMapStyle(googleMapStyler.getMapStyleOptions()); googleMap.setBuildingsEnabled(true); } });