/** * 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))); } }
case R.string.style_label_retro: style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_retro); break; case R.string.style_label_night: style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_night); break; case R.string.style_label_grayscale: style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_grayscale); break; case R.string.style_label_no_pois_no_transit: style = new MapStyleOptions("[" + " {" + " \"featureType\":\"poi.business\"," +
/** * 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; }
/** * 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(); }
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); }
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); } }
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()); } } }
@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); } }