當前位置: 首頁>>代碼示例>>Java>>正文


Java BitmapDescriptorFactory.fromBitmap方法代碼示例

本文整理匯總了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;
        }
 
開發者ID:Augugrumi,項目名稱:SpaceRace,代碼行數:19,代碼來源:PathDrawer.java

示例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);
}
 
開發者ID:stefanonicolai,項目名稱:AstronomyTourPadova,代碼行數:9,代碼來源:AtMarker.java

示例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);
}
 
開發者ID:ivicel,項目名稱:Android-Programming-BigNerd,代碼行數:26,代碼來源:LocatrFragment.java

示例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);
}
 
開發者ID:sharewire,項目名稱:google-maps-clustering,代碼行數:25,代碼來源:DefaultIconGenerator.java

示例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);
}
 
開發者ID:Augugrumi,項目名稱:SpaceRace,代碼行數:9,代碼來源:PiecePicker.java

示例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);
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:17,代碼來源:MapUtils.java

示例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);
}
 
開發者ID:mosquitolabs,項目名稱:referendum_1o_android,代碼行數:11,代碼來源:DefaultClusterOptionsProvider.java

示例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);
}
 
開發者ID:rsippl,項目名稱:AndroidProgramming3e,代碼行數:29,代碼來源:LocatrFragment.java

示例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();
            }
        }
    }
 
開發者ID:Elbehiry,項目名稱:Viajes,代碼行數:61,代碼來源:MapFragment.java

示例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);
	}
 
開發者ID:EduardoVernier,項目名稱:bikedeboa-android,代碼行數:59,代碼來源:AssetHelper.java

示例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();
}
 
開發者ID:gvinciguerra,項目名稱:custode,代碼行數:62,代碼來源:SummaryActivity.java


注:本文中的com.google.android.gms.maps.model.BitmapDescriptorFactory.fromBitmap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。