类com.google.android.gms.maps.model.MapStyleOptions源码实例Demo

下面列出了怎么用com.google.android.gms.maps.model.MapStyleOptions的API类实例代码及写法,或者点击链接到github查看源代码。

@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);
		}
	}
}
 
源代码2 项目: UberClone   文件: Home.java
@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);
}
 
源代码3 项目: Taxi-App-Android-XML   文件: Home.java
@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));


}
 
源代码4 项目: Nibo   文件: BaseNiboFragment.java
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());
        }
    }
}
 
源代码5 项目: journaldev   文件: MapsActivity.java
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);
        }
    }
 
源代码6 项目: UberClone   文件: DriverHome.java
@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));
}
 
源代码7 项目: UberClone   文件: TripDetail.java
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    googleMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(this, R.raw.uber_style_map));
    settingInformation();
}
 
源代码8 项目: Taxi-App-Android-XML   文件: MyTrip.java
@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));
}
 
源代码9 项目: ThemedGoogleMap   文件: GoogleMapStyler.java
/**
 * 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;
}
 
源代码10 项目: Saude-no-Mapa   文件: EstablishmentPresenterImpl.java
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(mContext, R.raw.map_style);
    mMap.setMapStyle(style);
    checkPermissions();
    configureMapClickListener();
}
 
源代码11 项目: Saude-no-Mapa   文件: EmergencyPresenterImpl.java
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(mContext, R.raw.map_style);
    mMap.setMapStyle(style);
    checkPermissions();
    configureMapClickListener();
}
 
源代码12 项目: snazzymaps-browser   文件: SnazzyMapsStyle.java
/**
 * 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());
    }
}
 
源代码13 项目: journaldev   文件: MapsActivity.java
/**
 * 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));

     **
     */

}
 
源代码14 项目: mage-android   文件: ProfileActivity.java
@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));
		}
	}
}
 
源代码15 项目: ThemedGoogleMap   文件: GoogleMapStyler.java
/**
 * Method returns the generated MapStyleOptions object to set to the google map.
 *
 * @return mapStyleOptions google map style options
 */
public MapStyleOptions getMapStyleOptions() {
    return mapStyleOptions;
}
 
源代码16 项目: ThemedGoogleMap   文件: GoogleMapStyler.java
/**
 * Method sets the MapStyleOptions object
 *
 * @param mapStyleOptions google map style options
 */
private void setMapStyleOptions(MapStyleOptions mapStyleOptions) {
    this.mapStyleOptions = mapStyleOptions;
}
 
 类方法
 同包方法