本文整理汇总了Java中com.google.android.gms.maps.model.BitmapDescriptorFactory.fromBitmap方法的典型用法代码示例。如果您正苦于以下问题:Java BitmapDescriptorFactory.fromBitmap方法的具体用法?Java BitmapDescriptorFactory.fromBitmap怎么用?Java BitmapDescriptorFactory.fromBitmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.maps.model.BitmapDescriptorFactory
的用法示例。
在下文中一共展示了BitmapDescriptorFactory.fromBitmap方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Builder
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入方法依赖的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;
}
示例2: bitmapDescriptorFromVector
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入方法依赖的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);
}
示例3: updateUI
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入方法依赖的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);
}
示例4: createClusterIcon
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入方法依赖的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);
}
示例5: getPiece
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入方法依赖的package包/类
@NonNull
public static BitmapDescriptor getPiece(@NonNull PieceShape shape, int id) {
Bitmap toScale = BitmapFactory.decodeResource(SpaceRace.getAppContext().getResources(), id);
toScale = Bitmap.createScaledBitmap(toScale, shape.getWidth(), shape.getLength(), false);
return BitmapDescriptorFactory.fromBitmap(toScale);
}
示例6: createLabelMarker
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入方法依赖的package包/类
/**
* Creates a marker for a label.
*
* @param iconFactory Reusable IconFactory
* @param id Id to be embedded as the title
* @param label Text to be shown on the label
*/
public static MarkerOptions createLabelMarker(IconGenerator iconFactory, String id,
LatLng position, String label) {
final BitmapDescriptor icon =
BitmapDescriptorFactory.fromBitmap(iconFactory.makeIcon(label));
return new MarkerOptions().position(position).title(id).icon(icon)
.anchor(0.5f, 0.5f)
.visible(false);
}
示例7: createIcon
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入方法依赖的package包/类
private BitmapDescriptor createIcon(int count) {
String text = String.valueOf(count);
calculateTextSize(text);
int iconSize = calculateIconSize();
Bitmap bitmap = Bitmap.createBitmap(iconSize, iconSize, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
drawCircle(canvas, count, iconSize);
drawText(canvas, text, iconSize);
return BitmapDescriptorFactory.fromBitmap(bitmap);
}
示例8: updateUI
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入方法依赖的package包/类
private void updateUI() {
if (mMap == null || mMapImage == null) {
return;
}
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);
}
示例9: setupMap
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入方法依赖的package包/类
private void setupMap() {
if (mMap != null) {
UiSettings settings = mMap.getUiSettings();
settings.setAllGesturesEnabled(true);
settings.setMyLocationButtonEnabled(true);
settings.setZoomControlsEnabled(true);
// LatLng latLng = null;
if (hotels.size() >0) {
// Hotel hotel = hotels.get(0);
// double mLatitude = hotel.getLat();
// double mLongitude = hotel.getLon();
// if (mLatitude == 0.0 && mLongitude == 0.0) {
// LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
// Location location = getLastKnownLocation(locationManager);
// if (location != null)
// latLng = new LatLng(location.getLatitude(), location.getLongitude());
// } else {
// latLng = new LatLng(mLatitude, mLongitude);
// }
//int size = getActivity().getResources().getDimensionPixelSize(R.dimen.fragment_map_marker_size);
Bitmap originalBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.placeholder);
Bitmap bitmap = BitmapScaler.scaleToFill(originalBitmap, 60, 60);
if(originalBitmap!=bitmap){
originalBitmap.recycle();
}
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
for (int i = 0; i < hotels.size(); i++) {
Hotel hotel = hotels.get(i);
LatLng latLng = new LatLng(hotel.getLat(),hotel.getLon());
options.position(latLng);
options.title(hotel.getName());
options.snippet("$ "+hotel.getPrice());
options.icon(bitmapDescriptor);
mMap.addMarker(options);
if (i == 0) {
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(latLng)
.zoom(MAP_ZOOM)
.bearing(0)
.tilt(0)
.build();
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
}
// if (latLng != null) {
// CameraPosition cameraPosition = new CameraPosition.Builder()
// .target(latLng)
// .zoom(MAP_ZOOM)
// .bearing(0)
// .tilt(0)
// .build();
// mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
// }
//setupClusterManager();
}
}
}
示例10: getCustomPin
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入方法依赖的package包/类
public static BitmapDescriptor getCustomPin(float rackScore, boolean mini) {
// Select correct resource
Drawable drawable = null;
if (rackScore == 0) {
if (mini) {
drawable = ResourcesCompat.getDrawable(resources, R.drawable.pin_gray_mini, null);
} else {
drawable = ResourcesCompat.getDrawable(resources, R.drawable.pin_gray, null);
}
} else if (rackScore > 0 && rackScore <= 2) {
if (mini) {
drawable = ResourcesCompat.getDrawable(resources, R.drawable.pin_red_mini, null);
} else {
drawable = ResourcesCompat.getDrawable(resources, R.drawable.pin_red, null);
}
} else if (rackScore > 2 && rackScore < 3.5) {
if (mini) {
drawable = ResourcesCompat.getDrawable(resources, R.drawable.pin_yellow_mini, null);
} else {
drawable = ResourcesCompat.getDrawable(resources, R.drawable.pin_yellow, null);
}
} else if (rackScore >= 3.5) {
if (mini) {
drawable = ResourcesCompat.getDrawable(resources, R.drawable.pin_green_mini, null);
} else {
drawable = ResourcesCompat.getDrawable(resources, R.drawable.pin_green, null);
}
}
float scale;
int alpha;
if (mini) {
scale = rackScore == 0 ? 0.4f : 0.1f + (rackScore / 10);
alpha = (int) (255 * 0.7);
} else {
scale = rackScore == 0 ? 0.8f : 0.6f + (rackScore / 10);
alpha = (int) (255 * 0.9);
}
Bitmap bitmap;
try {
// Svg was way too big, that's why I'm dividing by seven
// (mostly because I don't want to change the svgs too)
bitmap = Bitmap.createBitmap(
(int) (scale * drawable.getIntrinsicWidth() / 7),
(int) (scale * drawable.getIntrinsicHeight() / 7),
Bitmap.Config.ARGB_4444);
Canvas canvas = new Canvas(bitmap);
drawable.setAlpha(alpha);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
} catch (OutOfMemoryError e) {
return null;
}
return BitmapDescriptorFactory.fromBitmap(bitmap);
}
示例11: onCreate
import com.google.android.gms.maps.model.BitmapDescriptorFactory; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_summary);
overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left);
summaryTextView = (TextView) findViewById(R.id.summary_text_view);
summaryTextViewDefaultColor = summaryTextView.getTextColors();
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
contactsLinearLayout = (LinearLayout) findViewById(R.id.contacts_linear_layout);
shutdownButton = (FloatingActionButton) findViewById(R.id.shutdown_button);
shutdownButton.setOnClickListener(this);
int flags = WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
getWindow().addFlags(flags);
// TODO: Sostituisci con BitmapDescriptorFactory.fromResource(R.drawable.ic_message) quando https://code.google.com/p/gmaps-api-issues/issues/detail?id=9011 sarà corretto
Drawable vectorDrawable = ContextCompat.getDrawable(this, R.drawable.ic_message);
int w = vectorDrawable.getIntrinsicWidth();
int h = vectorDrawable.getIntrinsicHeight();
vectorDrawable.setBounds(0, 0, w, h);
Bitmap bm = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bm);
vectorDrawable.draw(canvas);
mapMarkerBitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bm);
// :ODOT
MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map_fragment);
mapFragment.getMapAsync(this);
smsUpdateReceiver = new SmsUpdateReceiver();
registerReceiver(smsUpdateReceiver, new IntentFilter("android.provider.Telephony.SMS_RECEIVED"));
sentSmsStatusReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
int contactIndex = intent.getIntExtra(CONTACT_INDEX_EXTRA, -1);
if (contactIndex < 0 || contactIndex >= favoriteContacts.size())
return;
boolean smsDelivered = intent.getAction().equals(SMS_STATUS_DELIVERED_ACTION);
RoundedContactBadge contactBadge = (RoundedContactBadge) contactsLinearLayout.getChildAt(contactIndex);
if (smsDelivered)
contactBadge.setContactStatus(RoundedContactBadge.ContactStatus.DELIVERED);
else {
boolean smsSent = getResultCode() == Activity.RESULT_OK;
contactBadge.setContactStatus(smsSent ? RoundedContactBadge.ContactStatus.SENT : RoundedContactBadge.ContactStatus.ERROR);
}
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(SMS_STATUS_SENT_ACTION);
filter.addAction(SMS_STATUS_DELIVERED_ACTION);
registerReceiver(sentSmsStatusReceiver, filter);
loadContactsIfNeeded();
if (savedInstanceState == null)
alertAllContacts();
}