本文整理汇总了Java中com.google.android.gms.maps.model.BitmapDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java BitmapDescriptor类的具体用法?Java BitmapDescriptor怎么用?Java BitmapDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BitmapDescriptor类属于com.google.android.gms.maps.model包,在下文中一共展示了BitmapDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addColorsToMarkers
import com.google.android.gms.maps.model.BitmapDescriptor; //导入依赖的package包/类
public static void addColorsToMarkers(GeoJsonLayer layer) {
// Iterate over all the features stored in the layer
for (GeoJsonFeature feature : layer.getFeatures()) {
// Check if the magnitude property exists
if (feature.getProperty("mag") != null && feature.hasProperty("place")) {
double magnitude = Double.parseDouble(feature.getProperty("mag"));
// Get the icon for the feature
BitmapDescriptor pointIcon = BitmapDescriptorFactory
.defaultMarker(magnitudeToColor(magnitude));
// Create a new point style
GeoJsonPointStyle pointStyle = new GeoJsonPointStyle();
// Set options for the point style
pointStyle.setIcon(pointIcon);
pointStyle.setTitle("Magnitude of " + magnitude);
pointStyle.setSnippet("Earthquake occured " + feature.getProperty("place"));
// Assign the point style to the feature
feature.setPointStyle(pointStyle);
}
}
}
示例2: Builder
import com.google.android.gms.maps.model.BitmapDescriptor; //导入依赖的package包/类
public Builder() {
Bitmap toScale = BitmapFactory.decodeResource(
SpaceRace.getAppContext().getResources(),
DEFAULT_PIECE_DISPLAYED);
toScale = Bitmap.createScaledBitmap(toScale,
ICON_DIMENSION,
ICON_DIMENSION,
false);
BitmapDescriptor defaultIcon = BitmapDescriptorFactory.fromBitmap(toScale);
this.firstNodeIcon = defaultIcon;
this.middleNodeIcon = defaultIcon;
this.lastNodeIcon = defaultIcon;
this.map = null;
this.path = null;
}
示例3: getMarker
import com.google.android.gms.maps.model.BitmapDescriptor; //导入依赖的package包/类
public MarkerOptions getMarker() {
BitmapDescriptor markerIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_location_red);
BitmapDescriptor markerIconMobile = BitmapDescriptorFactory.fromResource(R.drawable.ic_location_mobile_red);
this.marker.position(this.getCoordinates());
this.marker.title(this.name);
this.marker.snippet(this.getAddress() + this.getDates());
if(this.isMobile == null) {
this.marker.icon(markerIcon);
} else {
if(this.isMobile == true) {
this.marker.icon(markerIconMobile);
} else {
this.marker.icon(markerIcon);
}
}
return this.marker;
}
示例4: updateMapView
import com.google.android.gms.maps.model.BitmapDescriptor; //导入依赖的package包/类
private void updateMapView() {
if (mCurrent != null) {
mMap.clear();
// Add a marker for this item and set the camera
BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.icon_marker);
LatLng loc = new LatLng(mCurrent.getLatitude(), mCurrent.getLongitude());
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(loc, 13f));
mMap.addMarker(new MarkerOptions().position(loc).icon(icon));
// // Set the map type back to normal.
// mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
}
示例5: bitmapDescriptorFromVector
import com.google.android.gms.maps.model.BitmapDescriptor; //导入依赖的package包/类
private BitmapDescriptor bitmapDescriptorFromVector(Context context, int vectorResId) {
Drawable vectorDrawable = ContextCompat.getDrawable(context, vectorResId);
vectorDrawable.setBounds(0, 0, vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight());
Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
vectorDrawable.draw(canvas);
return BitmapDescriptorFactory.fromBitmap(bitmap);
}
示例6: updateUI
import com.google.android.gms.maps.model.BitmapDescriptor; //导入依赖的package包/类
private void updateUI() {
if (mMap == null || mMapImage == null) {
return;
}
Log.d(TAG, "updateUI: ");
LatLng itemPoint = new LatLng(mMapItem.getLat(), mMapItem.getLon());
LatLng myPoint = new LatLng(mCurrentLocation.getLatitude(),
mCurrentLocation.getLongitude());
BitmapDescriptor itemBitmap = BitmapDescriptorFactory.fromBitmap(mMapImage);
MarkerOptions itemMarker = new MarkerOptions()
.position(itemPoint)
.icon(itemBitmap);
MarkerOptions myMarker = new MarkerOptions()
.position(myPoint);
mMap.clear();
mMap.addMarker(itemMarker);
mMap.addMarker(myMarker);
LatLngBounds bounds = new LatLngBounds.Builder()
.include(itemPoint)
.include(myPoint)
.build();
int margin = getResources().getDimensionPixelSize(R.dimen.map_inset_margin);
CameraUpdate update = CameraUpdateFactory.newLatLngBounds(bounds, margin);
mMap.animateCamera(update);
}
示例7: createClusterIcon
import com.google.android.gms.maps.model.BitmapDescriptor; //导入依赖的package包/类
@NonNull
private BitmapDescriptor createClusterIcon(int clusterBucket) {
@SuppressLint("InflateParams")
TextView clusterIconView = (TextView) LayoutInflater.from(mContext)
.inflate(R.layout.map_cluster_icon, null);
clusterIconView.setBackground(createClusterBackground());
clusterIconView.setTextColor(mIconStyle.getClusterTextColor());
clusterIconView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
mIconStyle.getClusterTextSize());
clusterIconView.setText(getClusterIconText(clusterBucket));
clusterIconView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
clusterIconView.layout(0, 0, clusterIconView.getMeasuredWidth(),
clusterIconView.getMeasuredHeight());
Bitmap iconBitmap = Bitmap.createBitmap(clusterIconView.getMeasuredWidth(),
clusterIconView.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(iconBitmap);
clusterIconView.draw(canvas);
return BitmapDescriptorFactory.fromBitmap(iconBitmap);
}
示例8: addTag
import com.google.android.gms.maps.model.BitmapDescriptor; //导入依赖的package包/类
private void addTag(Context context, GoogleMap map, TagModel item, boolean addCache) {
LatLng location = new LatLng(item.getLatitude(), item.getLongitude());
BitmapDescriptor tagIcon = getTagIcon(item.getRoadCondition());
Marker marker = map.addMarker(new MarkerOptions()
.position(location)
.icon(tagIcon)
.anchor(0.5f, 0.5f)
.title(item.getName())
.snippet(item.getDescription()));
if (addCache && markersCache != null) {
markersCache.put(marker, item);
}
}
示例9: onLoadFinished
import com.google.android.gms.maps.model.BitmapDescriptor; //导入依赖的package包/类
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
MarkerData data = new MarkerData();
setCursorData(cursor, data);
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE);
Marker temp = mMap.addMarker(new MarkerOptions().position(new LatLng(data.getGeometry().getLocation().getLat(), data.getGeometry().getLocation().getLng())).title(data.getName()).icon(bitmapDescriptor));
hm.put(temp.getId(), data);
cursor.moveToNext();
Log.d(DEBUG, "Offline data : " + data);
}
addMarkerListner();
}
示例10: onMapReady
import com.google.android.gms.maps.model.BitmapDescriptor; //导入依赖的package包/类
/**
* 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;
// User loader to fetch data from SQLite
getSupportLoaderManager().initLoader(PLACE_MAP_LOADER, null, MapActivity.this);
Drawable circle = ContextCompat.getDrawable(MapActivity.this, R.drawable.ic_been_here);
Canvas canvas = new Canvas();
Bitmap bitmap = Bitmap.createBitmap(circle.getIntrinsicWidth(), circle.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
canvas.setBitmap(bitmap);
circle.setBounds(0, 0, circle.getIntrinsicWidth(), circle.getIntrinsicHeight());
circle.draw(canvas);
BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(bitmap);
// Add a marker in Sydney and move the camera
LatLng currentLocation = new LatLng(mLocation.getLatitude(), mLocation.getLongitude());
mMap.addMarker(new MarkerOptions().position(currentLocation).title("Here you are!").icon(icon));
mMap.moveCamera(CameraUpdateFactory.newLatLng(currentLocation));
mMap.animateCamera(CameraUpdateFactory.zoomTo(13.0f)); // zoom Range is 2.0 to 21.0
}
示例11: placeBootprint
import com.google.android.gms.maps.model.BitmapDescriptor; //导入依赖的package包/类
private void placeBootprint(LatLng latLng, float direction) {
if (mMap != null) {
final BitmapDescriptor bootprint;
// pick left/right print
if (mTotalSteps++ % 2 == 0) {
bootprint = mLeftBootprint;
} else {
bootprint = mRightBootprint;
}
final GroundOverlay overlay = mMap.addGroundOverlay(
new GroundOverlayOptions().position(
latLng,
BOOTPRINT_SIZE_METERS
).bearing(
(float) (direction / Math.PI * 180d)
).image(bootprint)
);
mBootprintLocations.add(overlay);
removeAndUpdateBootprints();
}
}
示例12: getBitmapDescriptorFromDrawable
import com.google.android.gms.maps.model.BitmapDescriptor; //导入依赖的package包/类
/**
* Creates a {@link BitmapDescriptor} from a drawable.
* This is particularly useful for {@link GoogleMap} {@link Marker}s.
*
* @param drawable The drawable that should be a {@link BitmapDescriptor}.
* @return The created {@link BitmapDescriptor}.
*/
@NonNull
public static BitmapDescriptor getBitmapDescriptorFromDrawable(@NonNull Drawable drawable) {
BitmapDescriptor bitmapDescriptor;
// Usually the pin could be loaded via BitmapDescriptorFactory directly.
// The target map_pin is a VectorDrawable which is currently not supported
// within BitmapDescriptors.
int width = drawable.getIntrinsicWidth();
int height = drawable.getIntrinsicHeight();
drawable.setBounds(0, 0, width, height);
Bitmap markerBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(markerBitmap);
drawable.draw(canvas);
bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(markerBitmap);
return bitmapDescriptor;
}
示例13: getBitmapDescriptorForCategory
import com.google.android.gms.maps.model.BitmapDescriptor; //导入依赖的package包/类
private BitmapDescriptor getBitmapDescriptorForCategory(String categoria) {
BitmapDescriptor mapIcon;
if (categoria.contains("consultório")) {
mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_consultorio);
} else if (categoria.contains("clínica")) {
mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_clinica);
} else if (categoria.contains("laboratório")) {
mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_laboratorio);
} else if (categoria.contains("urgência")) {
mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_urgente);
} else if (categoria.contains("hospital")) {
mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_hospital);
} else if (categoria.contains("atendimento domiciliar")) {
mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_domiciliar);
} else if (categoria.contains("posto de saúde")) {
mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_urgente);
} else if (categoria.contains("samu")) {
mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_samu);
} else {
mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_urgente);
}
return mapIcon;
}
示例14: drawLine
import com.google.android.gms.maps.model.BitmapDescriptor; //导入依赖的package包/类
/**
* Drw polyline on the Google Map from first and last LatLng
* @param first start point of the polyline to draw
* @param last last point of the polyline to draw
*/
public void drawLine(LatLng first, LatLng last){
// First you need rotate the bitmap of the arrowhead somewhere in your code
float rotationDegrees = (float) LatLngUtils.angleFromCoordinate(last.latitude, last.longitude, first.latitude, first.longitude);
// Create the rotated arrowhead bitmap
Bitmap arrow = BitmapFactory.decodeResource(getResources(), R.drawable.arrow);
BitmapDescriptor bitmapDescriptorFactory = BitmapDescriptorFactory.fromBitmap(arrow);
// Get the middle position
LatLng middlePos = LatLngUtils.midPoint(first.latitude, first.longitude, last.latitude, last.longitude);
// Now we are gonna to add a marker
Marker mArrowhead = googleMap.addMarker(new MarkerOptions()
.position(middlePos)
.flat(true)
.anchor(0.5f, 0.5f)
.rotation(rotationDegrees)
.icon(bitmapDescriptorFactory));
Polyline line = googleMap.addPolyline((new PolylineOptions())
.add(first, last).width(3).color(Color.parseColor("#9b24a6"))
.geodesic(true));
polylines.add(new Pair<Polyline, Marker>(line, mArrowhead));
}
示例15: createMarker
import com.google.android.gms.maps.model.BitmapDescriptor; //导入依赖的package包/类
private BitmapDescriptor createMarker(Drawable profilePic)
{
Drawable[] layers = new Drawable[2];
layers[0] = getResources().getDrawable(R.drawable.blue_marker);
layers[1] = profilePic;
LayerDrawable layerDrawable = new LayerDrawable(layers);
Bitmap b = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
// layerDrawable.setLayerInset(0, 0, 0, 0, 0);
layerDrawable.setLayerInset(1, 15, 13, 16, 18);
layerDrawable.setBounds(0, 0, 100, 100);
layerDrawable.draw(new Canvas(b));
BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(b);
return icon;
}