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; 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)); }
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 // Basic thing to do when the map is setup // Callback for when the googleMap object is set up public void onMapReady(GoogleMap googleMap) { // Make our map a map map = googleMap; Calendar current = Calendar.getInstance(); // Add night view for nice viewing when it's dark out // Dark styling is easier on the eyes SimpleDateFormat time = new SimpleDateFormat("HH:mm:ss"); if (nightTime(time.format(current.getTime()))) { MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(this, R.raw.maps_night_style); map.setMapStyle(style); } // Let's listen for clicks on our markers to display information map.setOnMarkerClickListener(showInfoWindow); }
@Override public void onMapReady(GoogleMap googleMap) { gMap = googleMap; Calendar current = Calendar.getInstance(); // Add night view for nice viewing when it's dark out // Dark styling is easier on the eyes SimpleDateFormat time = new SimpleDateFormat("HH:mm:ss"); if (nightTime(time.format(current.getTime()))) { MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(this, R.raw.maps_night_style); gMap.setMapStyle(style); } setupMap(request); }
@Override public void onMapReady(GoogleMap googleMap) { this.googleMap = googleMap; //googleMap.getUiSettings().setScrollGesturesEnabled(false); //googleMap.getUiSettings().setZoomControlsEnabled(false); //googleMap.getUiSettings().setZoomGesturesEnabled(false); googleMap.getUiSettings().setAllGesturesEnabled(false); googleMap.getUiSettings().setMapToolbarEnabled(false); googleMap.setOnMarkerClickListener( new GoogleMap.OnMarkerClickListener() { public boolean onMarkerClick(Marker marker) { return true; } }); MapStyleOptions mapStyle = MapStyleOptions.loadRawResourceStyle(this, R.raw.maps_json_styling); googleMap.setContentDescription("Map displaying selected route between " + start.getStopName() + " and " + destination.getStopName() + " with your vehicle location."); googleMap.setMapStyle(mapStyle); updateMap(); }
@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); } }
@Override public void onMapReady(GoogleMap googleMap) { this.map = googleMap; map.setMapStyle( MapStyleOptions.loadRawResourceStyle( this, SharedPreferencesManager.getMapStyle())); map.setMinZoomPreference(8.0f); }
@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)); }
/** * Called when the <code>GoogleMap</code> is ready. Initialize a MapHandler. * * @param googleMap the <code>GoogleMap</code> */ @Override public void onMapReady(GoogleMap googleMap) { MapStyleOptions mapStyle = MapStyleOptions.loadRawResourceStyle(getActivity(), R.raw.map_style_no_label); googleMap.setMapStyle(mapStyle); UtilsUI.recapDisplayTrackSetupUI(googleMap); UtilsUI.recapDisplayTrack(runToBeDisplayed.getTrack(), googleMap, ContextCompat.getColor(getContext(), R.color.colorAccent)); }
/** * Called when the GoogleMap is ready. Initializes a MapHandler. * * @param googleMap The GoogleMap, must be non null. */ @Override public void onMapReady(GoogleMap googleMap) { if (googleMap == null) { throw new IllegalArgumentException("The GoogleMap can't be null"); } MapStyleOptions mapStyle = MapStyleOptions.loadRawResourceStyle(getActivity(), R.raw.map_style_no_label); googleMap.setMapStyle(mapStyle); mapHandler = new MapHandler(googleMap, ContextCompat.getColor(getContext(), R.color.colorAccent)); mapHandler.setupRunningMapUI(); }
/** * Called when the GoogleMap is ready. Initialize a MapHandler. * * @param googleMap The GoogleMap must be non null. */ @Override public void onMapReady(GoogleMap googleMap) { if (googleMap == null) { throw new IllegalArgumentException("The GoogleMap must be non null"); } MapStyleOptions mapStyle = MapStyleOptions.loadRawResourceStyle(getActivity(), R.raw.map_style_no_label); googleMap.setMapStyle(mapStyle); mapHandler = new MapHandler(googleMap, ContextCompat.getColor(getContext(), R.color.colorAccent)); }
/** * Called when the <code>GoogleMap</code> is ready. Initialize a MapHandler. * * @param googleMap the <code>GoogleMap</code> */ @Override public void onMapReady(GoogleMap googleMap) { MapStyleOptions mapStyle = MapStyleOptions.loadRawResourceStyle(getActivity(), R.raw.map_style_no_label); switch(currentMapType) { case USER_MAP: Track userTrack = challengeToBeDisplayed.getMyRun().getTrack(); googleMap.setMapStyle(mapStyle); UtilsUI.recapDisplayTrack(userTrack, googleMap, userColor); UtilsUI.recapDisplayTrackSetupUI(googleMap); currentMapType = MapType.OPPONENT_MAP; opponentMapView.getMapAsync(this); break; case OPPONENT_MAP: Track opponentTrack = challengeToBeDisplayed.getOpponentRun().getTrack(); googleMap.setMapStyle(mapStyle); UtilsUI.recapDisplayTrack(opponentTrack, googleMap, opponentColor); UtilsUI.recapDisplayTrackSetupUI(googleMap); break; default: throw new IllegalStateException("unknown map type"); } }
@Override public void onMapReady(GoogleMap map) { googleMap = map; try { googleMap.setMapStyle( MapStyleOptions.loadRawResourceStyle( this.getContext(), R.raw.style_json)); googleMap.setMyLocationEnabled(true); if (location != null){ loadLocationByLatLng(); } }catch (SecurityException e){} }
/** * 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; }
@Override // Basic thing to do when the map is setup // Callback for when the googleMap object is set up public void onMapReady(GoogleMap googleMap) { // Make our map a map map = googleMap; // Allow the user to go home at any time map.setMyLocationEnabled(true); map.setOnMapLongClickListener(searchAtPoint); // What time is it? Calendar current = Calendar.getInstance(); // Add night view for nice viewing when it's dark out // Dark styling is easier on the eyes SimpleDateFormat time = new SimpleDateFormat("HH:mm:ss"); if (nightTime(time.format(current.getTime()))) { MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(this, R.raw.maps_night_style); map.setMapStyle(style); } // Let's listen for clicks on our markers to display information map.setOnMarkerClickListener(showInfoWindow); map.setOnInfoWindowClickListener(goToRequest); map.setInfoWindowAdapter(displayRequest); }
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(mContext, R.raw.map_style); mMap.setMapStyle(style); checkPermissions(); configureMapClickListener(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_projection_route); View view = new FrameLayout(this); mSpinner = findViewById(R.id.spinner_location); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.array_place, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner mSpinner.setAdapter(adapter); mSpinner.setOnItemSelectedListener(this); mSwitchCompat = findViewById(R.id.switch_btn); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window w = getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } mapFragment = (TrailSupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this); route = Data.getRoute(); mapStyle = MapStyleOptions.loadRawResourceStyle(getApplicationContext(), R.raw.mapstyle); }
/** * 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()); } }
@Override public void onMapReady(GoogleMap googleMap) { // Initialise marker icons. ICON_ACTIVE = BitmapDescriptorFactory.fromBitmap( UIUtils.drawableToBitmap(getContext(), R.drawable.map_marker_selected)); ICON_NORMAL = BitmapDescriptorFactory.fromBitmap( UIUtils.drawableToBitmap(getContext(), R.drawable.map_marker_unselected)); mMap = googleMap; mMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(getContext(), R.raw.maps_style)); mMap.setIndoorEnabled(false); mMap.setOnMarkerClickListener(this); mMap.setOnMapClickListener(this); mMap.setLatLngBoundsForCameraTarget(VIEWPORT); mMap.setMinZoomPreference(BuildConfig.MAP_VIEWPORT_MINZOOM); UiSettings mapUiSettings = mMap.getUiSettings(); mapUiSettings.setZoomControlsEnabled(false); mapUiSettings.setMapToolbarEnabled(false); // This state is set via 'setMyLocationLayerEnabled. //noinspection MissingPermission mMap.setMyLocationEnabled(mMyLocationEnabled); // Move camera directly to the venue centerOnVenue(false); loadMapData(); LOGD(TAG, "Map setup complete."); }
@Override public boolean setMapStyle(MapStyleOptions mapStyleOptions) { return real.setMapStyle(mapStyleOptions); }
@Override public boolean setMapStyle(MapStyleOptions mapStyleOptions) { return map.setMapStyle(mapStyleOptions); }
public void setup() { MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(Application.getContext(), R.raw.map_style); this.googleMap.setMapStyle(style); if (ActivityCompat.checkSelfPermission(Application.getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(Application.getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, GET_PERMS); return; } setupLocationChangeListener(); if (!locationServiceEnabled) { locationSettingsRequest(Application.getContext()); return; } isTracking = true; if (gpsTracking == null) { gpsTracking = new GPSTracking(getContext()); } googleMap.setMyLocationEnabled(false); googleMap.setBuildingsEnabled(false); googleMap.getUiSettings().setCompassEnabled(false); googleMap.getUiSettings().setMyLocationButtonEnabled(false); googleMap.getUiSettings().setMapToolbarEnabled(false); /* FIREBASE TRACKING SETUP */ setTrackingReference(); /* USING CUSTOM GPS TRACKING MARKER */ LatLng currentLocation = new LatLng(gpsTracking.getLatitude(), gpsTracking.getLongitude()); Bitmap myLocationMarker = BitmapFactory.decodeResource(getResources(), R.drawable.navigation); Bitmap scaledLocation = Bitmap.createScaledBitmap(myLocationMarker, 72, 72, false); setCameraPosition(gpsTracking.getLatitude(), gpsTracking.getLongitude(), standardZoomLevel, false); myLocation = googleMap.addMarker(new MarkerOptions() .position(currentLocation) .flat(true) .icon(BitmapDescriptorFactory.fromBitmap(scaledLocation)) .anchor(0.5f, 0.5f) ); myLocation.setTag(0); nearbyRadius(currentLocation); //accuracyCircle(currentLocation, gpsTracking.getLocation().getAccuracy()); trackingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!isTracking) { isTracking = true; trackingButton.setImageTintList(ColorStateList.valueOf(getResources().getColor(R.color.colorPrimary))); if (listenerLocation != null) { setCameraPosition(listenerLocation.getLatitude(), listenerLocation.getLongitude(), standardZoomLevel, true); } else { setCameraPosition(gpsTracking.getLatitude(), gpsTracking.getLongitude(), standardZoomLevel, true); } if (selectedMarker != null) resetMarkerIcon(selectedMarker); } } }); if (user != null) { shareReference.addChildEventListener(staticLocationListener); } }
@Override public boolean setMapStyle(MapStyleOptions mapStyleOptions) { return googleMap.setMapStyle(mapStyleOptions); }
public boolean setMapStyle(MapStyleOptions mapStyleOptions) { return false; //// TODO: 30/08/17 }
@Override public void mapTypeSelected(int type) { // 1 is night, -1 is day. short becomesNight = 0; // Map type! if(mMap != null) { switch(type) { case GoogleMap.MAP_TYPE_NORMAL: mMap.setMapStyle(null); becomesNight = -1; // Let's abuse a fallthrough! case GoogleMap.MAP_TYPE_HYBRID: case GoogleMap.MAP_TYPE_TERRAIN: mMap.setMapType(type); break; case MapTypeDialogFragment.MAP_STYLE_NIGHT: // Whoops, this one isn't a type. It's a style. First, the // type has to be normal for this to work. mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); // Then, load up the night style. if(!mMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(this, R.raw.map_night))) Log.e(DEBUG_TAG, "Couldn't parse the map style JSON!"); becomesNight = 1; break; } } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor edit = prefs.edit(); edit.putInt(GHDConstants.PREF_LAST_MAP_TYPE, type); edit.apply(); BackupManager bm = new BackupManager(this); bm.dataChanged(); // Set the night only if it's changed at all. if(becomesNight == 1) setNightMode(true); else if(becomesNight == -1) setNightMode(false); }
/** * Manipulates the map once available. * This callback is triggered when the map is ready to be used. * 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) { map = googleMap; if (map == null) return; map.setMapStyle(MapStyleOptions.loadRawResourceStyle(getContext(), R.raw.map_style)); map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(22.3964, 114.1095), 10)); GoogleMapOptions options = new GoogleMapOptions(); options.mapToolbarEnabled(false); options.compassEnabled(true); options.rotateGesturesEnabled(true); options.scrollGesturesEnabled(false); options.tiltGesturesEnabled(true); options.zoomControlsEnabled(false); options.zoomGesturesEnabled(true); map.setBuildingsEnabled(false); map.setIndoorEnabled(false); map.setTrafficEnabled(false); map.setOnMarkerClickListener(this); if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { map.setMyLocationEnabled(true); } if (busRouteStops != null && busRouteStops.size() > 0) { PolylineOptions line = new PolylineOptions().width(20).zIndex(1) .color(ContextCompat.getColor(getContext(), R.color.colorAccent)); for (BusRouteStop stop: busRouteStops) { LatLng latLng = new LatLng(Double.parseDouble(stop.latitude), Double.parseDouble(stop.longitude)); line.add(latLng); IconGenerator iconFactory = new IconGenerator(getContext()); Bitmap bmp = iconFactory.makeIcon(stop.sequence + ": " + stop.name); map.addMarker(new MarkerOptions().position(latLng) .icon(BitmapDescriptorFactory.fromBitmap(bmp))).setTag(stop); } line.startCap(new RoundCap()); line.endCap(new RoundCap()); map.addPolyline(line); if (busRouteStops.size() < goToStopPos) { goToStopPos = 0; } map.moveCamera(CameraUpdateFactory.newLatLngZoom( new LatLng(Double.parseDouble(busRouteStops.get(goToStopPos).latitude), Double.parseDouble(busRouteStops.get(goToStopPos).longitude)), 16)); } }
@SuppressWarnings("MissingPermission") @Override public void onMapReady(final GoogleMap mMap) { MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(this, R.raw.map); mMap.setMapStyle(style); LatLng location = getIntent().getParcelableExtra("location"); if (location == null) { mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API) .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() { @Override public void onConnected(final Bundle bundle) { android.location.Location l = LocationServices.FusedLocationApi .getLastLocation(mGoogleApiClient); if (l != null && mMap.getCameraPosition().zoom <= 2) { mMap.moveCamera(CameraUpdateFactory.newLatLngZoom( new LatLng(l.getLatitude(), l.getLongitude()), 16)); } mGoogleApiClient.disconnect(); } @Override public void onConnectionSuspended(int cause) { if (BuildConfig.DEBUG) Logger.log("connection suspended: " + cause); } }).build(); mGoogleApiClient.connect(); mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(final LatLng center) { getIntent().putExtra("location", center); setResult(RESULT_OK, getIntent()); finish(); } }); } else { mMap.addCircle(new CircleOptions().center(location).radius(100).strokeColor(Color.BLUE) .fillColor(Color.argb(64, 0, 0, 255))); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 16)); } mMap.setMyLocationEnabled(true); }
/** * Method returns the generated MapStyleOptions object to set to the google map. * * @return mapStyleOptions google map style options */ public MapStyleOptions getMapStyleOptions() { return mapStyleOptions; }
/** * Method sets the MapStyleOptions object * * @param mapStyleOptions google map style options */ private void setMapStyleOptions(MapStyleOptions mapStyleOptions) { this.mapStyleOptions = mapStyleOptions; }
boolean setMapStyle(MapStyleOptions mapStyleOptions);
public boolean setMapStyle(MapStyleOptions mapStyleOptions);