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

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

源代码1 项目: FimiX8-RE   文件: GglMapAiLineManager.java
public void setAiLineMarkByHistory(List<X8AiLinePointLatlngInfo> points, int mapTpye) {
    for (X8AiLinePointLatlngInfo point : points) {
        int res;
        MapPointLatLng mp = new MapPointLatLng();
        if (point.getYawMode() == 0) {
            res = R.drawable.x8_ai_line_point_no_angle2;
        } else {
            res = R.drawable.x8_ai_line_point_with_angle1;
        }
        BitmapDescriptor mBitmapDescriptor = this.gdCustemMarkerView.createCustomMarkerView2(this.context, res, this.mMarkerList.size() + 1);
        mp.altitude = (float) point.getAltitude();
        mp.nPos = this.mMarkerList.size() + 1;
        LatLng latLng = new LatLng(point.getLatitude(), point.getLongitude());
        Marker mMarker = this.googleMap.addMarker(new MarkerOptions().position(latLng).icon(mBitmapDescriptor).anchor(0.5f, 0.5f).draggable(false));
        mp.longitude = latLng.longitude;
        mp.latitude = latLng.latitude;
        mMarker.setFlat(true);
        mMarker.setTag(mp);
        this.mMarkerList.add(mMarker);
        mp.distance = 0.0f;
        this.mMapPointList.add(mp);
    }
    if (points.size() > 0) {
        drawPointLine(this.gglMapLocationManager.getDevLocation());
    }
}
 
源代码2 项目: FimiX8-RE   文件: GglMapAiLineManager.java
public void changeAngleOrOnAngle(Marker marker, MapPointLatLng mpl, boolean isRelation) {
    BitmapDescriptor mBitmapDescriptor;
    int res;
    if (mpl.yawMode == 1 || mpl.yawMode == 2) {
        if (mpl.isSelect) {
            res = R.drawable.x8_ai_line_point_with_angle2;
        } else {
            res = R.drawable.x8_ai_line_point_with_angle1;
        }
        mBitmapDescriptor = this.gdCustemMarkerView.createMapPointAngleNoPioView(this.context, res, mpl.altitude, mpl.nPos, mpl.showAngle, mpl.isSelect, isRelation);
    } else {
        if (mpl.isSelect) {
            res = R.drawable.x8_ai_line_point_no_angle2;
        } else {
            res = R.drawable.x8_ai_line_point_no_angle1;
        }
        mBitmapDescriptor = this.gdCustemMarkerView.createMapPointNoAngleNoPioView(this.context, res, mpl.altitude, mpl.nPos, mpl.isSelect, isRelation);
    }
    marker.setIcon(mBitmapDescriptor);
    marker.setAnchor(0.5f, 0.64285713f);
}
 
源代码3 项目: FimiX8-RE   文件: GglMapAiLineManager.java
public Marker addPointMarker(boolean isMapPoint, LatLng latLng, MapPointLatLng mpl, float h, float angle) {
    BitmapDescriptor mBitmapDescriptor;
    float anchorY;
    if (isMapPoint) {
        mBitmapDescriptor = this.gdCustemMarkerView.createMapPointNoAngleNoPioView(this.context, R.drawable.x8_ai_line_point_no_angle1, h, mpl.nPos, mpl.isSelect, false);
        mpl.altitude = h;
        mpl.isMapPoint = isMapPoint;
        anchorY = 0.64285713f;
        int res = 0;
    } else {
        mpl.angle = angle;
        mpl.showAngle = angle;
        mBitmapDescriptor = this.gdCustemMarkerView.createMapPointAngleNoPioView(this.context, R.drawable.x8_ai_line_point_with_angle1, mpl.altitude, mpl.nPos, mpl.showAngle, mpl.isSelect, false);
        mpl.altitude = h;
        mpl.isMapPoint = isMapPoint;
        anchorY = 0.5f;
    }
    Marker mMarker = this.googleMap.addMarker(new MarkerOptions().position(latLng).icon(mBitmapDescriptor).anchor(0.5f, anchorY).draggable(false));
    mMarker.setFlat(true);
    return mMarker;
}
 
源代码4 项目: FimiX8-RE   文件: GglMapAiLineManager.java
public Marker addPointMarkerByHistory(MapPointLatLng mpl) {
    BitmapDescriptor mBitmapDescriptor;
    float anchorY;
    if (this.lineMarkerSelectListener.getOration() != 0) {
        mBitmapDescriptor = this.gdCustemMarkerView.createMapPointAngleNoPioView(this.context, R.drawable.x8_ai_line_point_with_angle1, mpl.altitude, mpl.nPos, mpl.showAngle, mpl.isSelect, false);
        anchorY = 0.64285713f;
    } else if (mpl.mInrertestPoint != null) {
        mpl.setAngle(getPointAngle(mpl, mpl.mInrertestPoint));
        mBitmapDescriptor = this.gdCustemMarkerView.createMapPointAngleNoPioView(this.context, R.drawable.x8_ai_line_point_with_angle1, mpl.altitude, mpl.nPos, mpl.showAngle, mpl.isSelect, false);
        anchorY = 0.64285713f;
    } else {
        mBitmapDescriptor = this.gdCustemMarkerView.createMapPointNoAngleNoPioView(this.context, R.drawable.x8_ai_line_point_no_angle1, mpl.altitude, mpl.nPos, mpl.isSelect, false);
        anchorY = 0.64285713f;
    }
    Marker marker = this.googleMap.addMarker(new MarkerOptions().position(new LatLng(mpl.latitude, mpl.longitude)).icon(mBitmapDescriptor).anchor(0.5f, anchorY).draggable(false));
    marker.setFlat(true);
    return marker;
}
 
源代码5 项目: animation-samples   文件: ViewUtils.java
/**
 * 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;
}
 
源代码6 项目: ground-android   文件: MarkerIconFactory.java
public BitmapDescriptor getMarkerIcon(int color) {
  Drawable outline = AppCompatResources.getDrawable(context, R.drawable.ic_marker_outline);
  Drawable fill = AppCompatResources.getDrawable(context, R.drawable.ic_marker_fill);
  Drawable overlay = AppCompatResources.getDrawable(context, R.drawable.ic_marker_overlay);
  // TODO: Define scale in resources.
  // TODO: Adjust size based on zoom level and selection state.
  float scale = 1.8f;
  int width = (int) (outline.getIntrinsicWidth() * scale);
  int height = (int) (outline.getIntrinsicHeight() * scale);
  Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
  Canvas canvas = new Canvas(bitmap);
  outline.setBounds(0, 0, width, height);
  outline.draw(canvas);
  fill.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
  fill.setBounds(0, 0, width, height);
  fill.draw(canvas);
  overlay.setBounds(0, 0, width, height);
  overlay.draw(canvas);
  // TODO: Cache rendered bitmaps.
  return BitmapDescriptorFactory.fromBitmap(bitmap);
}
 
@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);
}
 
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;
}
 
源代码9 项目: Saude-no-Mapa   文件: EmergencyInteractorImpl.java
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;
}
 
源代码10 项目: android-app   文件: MapMarker.java
private BitmapDescriptor getIcon(Date data) {
    DateTime current = new DateTime(Calendar.getInstance());
    DateTime last = new DateTime(data);
    int diff =  Minutes.minutesBetween(last, current).getMinutes();

    BitmapDescriptor bitmap;

    if(diff >= 5 && diff < 10 ) {
        bitmap = BitmapDescriptorFactory
                .fromResource(R.drawable.bus_yellow);
    }  else if(diff >= 10 ) {
       bitmap = BitmapDescriptorFactory
            .fromResource(R.drawable.bus_red);
    } else {
        bitmap = BitmapDescriptorFactory
                .fromResource(R.drawable.bus_green);
    }
    return bitmap;
}
 
源代码11 项目: android-maps-utils   文件: GeoJsonDemoActivity.java
/**
 * Adds a point style to all features to change the color of the marker based on its magnitude
 * property
 */
private 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);
        }
    }
}
 
/**
 * Get a descriptor for multiple people (a cluster) to be used for a marker icon. Note: this
 * method runs on the UI thread. Don't spend too much time in here (like in this example).
 *
 * @param cluster cluster to draw a BitmapDescriptor for
 * @return a BitmapDescriptor representing a cluster
 */
private BitmapDescriptor getClusterIcon(Cluster<Person> cluster) {
    List<Drawable> profilePhotos = new ArrayList<>(Math.min(4, cluster.getSize()));
    int width = mDimension;
    int height = mDimension;

    for (Person p : cluster.getItems()) {
        // Draw 4 at most.
        if (profilePhotos.size() == 4) break;
        Drawable drawable = getResources().getDrawable(p.profilePhoto);
        drawable.setBounds(0, 0, width, height);
        profilePhotos.add(drawable);
    }
    MultiDrawable multiDrawable = new MultiDrawable(profilePhotos);
    multiDrawable.setBounds(0, 0, width, height);

    mClusterImageView.setImageDrawable(multiDrawable);
    Bitmap icon = mClusterIconGenerator.makeIcon(String.valueOf(cluster.getSize()));
    return BitmapDescriptorFactory.fromBitmap(icon);
}
 
源代码13 项目: android-maps-utils   文件: Renderer.java
/**
 * Gets a cached image at the specified scale which is needed for Marker icon images.
 * If a BitmapDescriptor doesn't exist in the cache, the Bitmap for the URL from the
 * bitmap cache is scaled and cached as a BitmapDescriptor.
 *
 * @param url URL to get cached image for
 * @param scale scale to get image at
 * @return scaled BitmapDescriptor
 */
protected BitmapDescriptor getCachedMarkerImage(String url, double scale) {
    String scaleString = sScaleFormat.format(scale);
    Map<String, BitmapDescriptor> bitmaps = mImagesCache.markerImagesCache.get(url);
    BitmapDescriptor bitmapDescriptor = null;
    if (bitmaps != null) {
        bitmapDescriptor = bitmaps.get(scaleString);
    }
    if (bitmapDescriptor == null) {
        Bitmap bitmap = mImagesCache.bitmapCache.get(url);
        if (bitmap != null) {
            bitmapDescriptor = scaleIcon(bitmap, scale);
            putMarkerImagesCache(url, scaleString, bitmapDescriptor);
        }
    }
    return bitmapDescriptor;
}
 
源代码14 项目: android-maps-utils   文件: Renderer.java
/**
 * Scales a bitmap by a specified float, taking into account the display density such
 * that the bitmap is scaled for a standard sized KML point marker.
 *
 * @param unscaledBitmap Unscaled bitmap image to scale.
 * @param scale          Scale value. A "1.0" scale value corresponds to the original size of the Bitmap
 * @return A scaled bitmap image
 */
private BitmapDescriptor scaleIcon(Bitmap unscaledBitmap, double scale) {
    float density = mContext.getResources().getDisplayMetrics().density;
    int minSize = (int) (MARKER_ICON_SIZE * density * scale);

    int unscaledWidth = unscaledBitmap.getWidth();
    int unscaledHeight = unscaledBitmap.getHeight();

    int width;
    int height;
    if (unscaledWidth < unscaledHeight) {
        width = minSize;
        height = (int) ((float) (minSize * unscaledHeight) / (float) unscaledWidth);
    } else if (unscaledWidth > unscaledHeight) {
        width = (int) ((float) (minSize * unscaledWidth) / (float) unscaledHeight);
        height = minSize;
    } else {
        width = minSize;
        height = minSize;
    }

    Bitmap scaledBitmap = Bitmap.createScaledBitmap(unscaledBitmap, width, height, false);
    return BitmapDescriptorFactory.fromBitmap(scaledBitmap);
}
 
源代码15 项目: android-maps-utils   文件: KmlRenderer.java
/**
 * Adds ground overlays from a given URL onto the map
 *
 * @param groundOverlayUrl url of ground overlay
 * @param groundOverlays   hashmap of ground overlays to add to the map
 */
private void addGroundOverlayToMap(String groundOverlayUrl,
                                   HashMap<KmlGroundOverlay, GroundOverlay> groundOverlays, boolean containerVisibility) {
    BitmapDescriptor groundOverlayBitmap = getCachedGroundOverlayImage(groundOverlayUrl);
    for (KmlGroundOverlay kmlGroundOverlay : groundOverlays.keySet()) {
        if (kmlGroundOverlay.getImageUrl().equals(groundOverlayUrl)) {
            GroundOverlayOptions groundOverlayOptions = kmlGroundOverlay.getGroundOverlayOptions()
                    .image(groundOverlayBitmap);
            GroundOverlay mapGroundOverlay = attachGroundOverlay(groundOverlayOptions);
            if (!containerVisibility) {
                mapGroundOverlay.setVisible(false);
            }
            groundOverlays.put(kmlGroundOverlay, mapGroundOverlay);
        }
    }
}
 
源代码16 项目: FimiX8-RE   文件: GglMapCustomMarkerView.java
public BitmapDescriptor createCustomMarkerViewForP2P(Context context, int res, float heightVale, int npos) {
    View view = LayoutInflater.from(context).inflate(R.layout.x8_map_custom_mark_view_for_point, null);
    ((TextView) view.findViewById(R.id.point_heightValue)).setText(X8NumberUtil.getDistanceNumberString(heightVale, 0, true));
    ImageView imageView = (ImageView) view.findViewById(R.id.markerIcon);
    if (res != 0) {
        imageView.setBackgroundResource(res);
    }
    return BitmapDescriptorFactory.fromBitmap(loadBitmapFromView(view, context));
}
 
源代码17 项目: FimiX8-RE   文件: GglMapCustomMarkerView.java
public BitmapDescriptor createCustomMarkerView(Context context, int res, float heightVale, int npos) {
    View view = LayoutInflater.from(context).inflate(R.layout.x8_map_custom_mark_view, null);
    TextView heightView = (TextView) view.findViewById(R.id.point_heightValue);
    ((TextView) view.findViewById(R.id.tv_pos)).setText("" + npos);
    heightView.setText(X8NumberUtil.getDistanceNumberString(heightVale, 0, true));
    ImageView imageView = (ImageView) view.findViewById(R.id.markerIcon);
    if (res != 0) {
        imageView.setBackgroundResource(res);
    }
    return BitmapDescriptorFactory.fromBitmap(loadBitmapFromView(view, context));
}
 
源代码18 项目: FimiX8-RE   文件: GglMapCustomMarkerView.java
public BitmapDescriptor createCustomMarkerView2(Context context, int res, int nPos) {
    View view = LayoutInflater.from(context).inflate(R.layout.x8_map_custom_mark_view2, null);
    ((TextView) view.findViewById(R.id.point_heightValue)).setText("" + nPos);
    ImageView imageView = (ImageView) view.findViewById(R.id.markerIcon);
    if (res != 0) {
        imageView.setBackgroundResource(res);
    }
    return BitmapDescriptorFactory.fromBitmap(loadBitmapFromView(view, context));
}
 
源代码19 项目: FimiX8-RE   文件: GglMapCustomMarkerView.java
public BitmapDescriptor createCurrentPointView(Context context, int res, int actionRes, int nPos) {
    View view = LayoutInflater.from(context).inflate(R.layout.x8_map_custom_mark_view4, null);
    ImageView imageView = (ImageView) view.findViewById(R.id.img_point);
    if (res != 0) {
        imageView.setBackgroundResource(res);
    }
    ImageView imageView2 = (ImageView) view.findViewById(R.id.img_action);
    if (res != 0) {
        imageView2.setBackgroundResource(actionRes);
    }
    ((TextView) view.findViewById(R.id.tv_index)).setText("" + nPos);
    return BitmapDescriptorFactory.fromBitmap(loadBitmapFromView(view, context));
}
 
源代码20 项目: FimiX8-RE   文件: GglMapCustomMarkerView.java
public BitmapDescriptor createPointWithSmallArrow(Context context, int res, float angle, boolean isShow) {
    View view = LayoutInflater.from(context).inflate(R.layout.x8_map_marker_arrow_view, null);
    ImageView imageView = (ImageView) view.findViewById(R.id.markerIcon);
    if (res != 0) {
        imageView.setBackgroundResource(res);
        imageView.setRotation(angle);
    }
    if (!isShow) {
        imageView.setVisibility(4);
    }
    return BitmapDescriptorFactory.fromBitmap(loadBitmapFromView(view, context));
}
 
源代码21 项目: FimiX8-RE   文件: GglMapAiSurroundManager.java
public void setAiSurroundMark(double latitude, double logitude) {
    FLatLng fLatLng = GpsCorrect.Earth_To_Mars(latitude, logitude);
    LatLng latLng = new LatLng(fLatLng.latitude, fLatLng.longitude);
    if (this.pointMarker == null) {
        BitmapDescriptor mBitmapDescriptor = new GglMapCustomMarkerView().createCustomMarkerView(this.context, R.drawable.x8_img_ai_follow_point2);
        this.mp = new MapPointLatLng();
        this.pointMarker = this.googleMap.addMarker(new MarkerOptions().position(latLng).icon(mBitmapDescriptor).anchor(0.5f, 0.5f).draggable(true));
        this.pointMarker.setTag(this.mp);
        return;
    }
    this.pointMarker.setPosition(latLng);
}
 
源代码22 项目: animation-samples   文件: DetailMarkerRenderer.java
@NonNull
private BitmapDescriptor getMapPin() {
    if (mMapPin == null) {
        mMapPin = ViewUtils.getBitmapDescriptorFromDrawable(mMarkerDrawable);
    }
    return mMapPin;
}
 
private BitmapDescriptor convertDrawableToBitmap(Drawable drawable)
{
	Canvas canvas = new Canvas();
	Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
	canvas.setBitmap(bitmap);
	drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
	drawable.draw(canvas);
	return BitmapDescriptorFactory.fromBitmap(bitmap);
}
 
源代码24 项目: GNSS_Compare   文件: MapFragment.java
/**
 * Demonstrates converting a {@link Drawable} to a {@link BitmapDescriptor},
 * for use as a marker icon.
 */
private BitmapDescriptor vectorToBitmap(@DrawableRes int id, @ColorInt int color) {
    Drawable vectorDrawable = ResourcesCompat.getDrawable(getResources(), id, null);
    Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(),
            vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    DrawableCompat.setTint(vectorDrawable, color);
    vectorDrawable.draw(canvas);
    return BitmapDescriptorFactory.fromBitmap(bitmap);
}
 
源代码25 项目: ground-android   文件: GoogleMapsMapAdapter.java
private void addMapPin(MapPin mapPin) {
  LatLng position = toLatLng(mapPin.getPosition());
  String color = mapPin.getStyle().getColor();
  BitmapDescriptor icon = markerIconFactory.getMarkerIcon(parseColor(color));
  Marker marker = map.addMarker(new MarkerOptions().position(position).icon(icon).alpha(1.0f));
  marker.setTag(mapPin);
  markers.add(marker);
}
 
源代码26 项目: AndroidProgramming3e   文件: LocatrFragment.java
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);
}
 
@NonNull
public BitmapDescriptor getClusterIcon(@NonNull Cluster<T> cluster) {
    int clusterBucket = getClusterIconBucket(cluster);
    BitmapDescriptor clusterIcon = mClusterIcons.get(clusterBucket);

    if (clusterIcon == null) {
        clusterIcon = createClusterIcon(clusterBucket);
        mClusterIcons.put(clusterBucket, clusterIcon);
    }

    return clusterIcon;
}
 
@NonNull
@Override
public BitmapDescriptor getClusterItemIcon(@NonNull T clusterItem) {
    if (mClusterItemIcon == null) {
        mClusterItemIcon = createClusterItemIcon();
    }
    return mClusterItemIcon;
}
 
源代码29 项目: google-maps-clustering   文件: ClusterRenderer.java
@NonNull
private BitmapDescriptor getMarkerIcon(@NonNull Cluster<T> cluster) {
    BitmapDescriptor clusterIcon;

    List<T> clusterItems = cluster.getItems();
    if (clusterItems.size() > 1) {
        clusterIcon = mIconGenerator.getClusterIcon(cluster);
    } else {
        clusterIcon = mIconGenerator.getClusterItemIcon(clusterItems.get(0));
    }

    return checkNotNull(clusterIcon);
}
 
源代码30 项目: RxGpsService   文件: PlaceMapFragment.java
private BitmapDescriptor getIconRoute() {
    if (iconRoute == null) {
        Bitmap bitmap = bitmapHelper.getBitmap(getContext(), R.drawable.ic_assistant_photo);
        bitmap = bitmapHelper.getTintedBitmap(bitmap, ContextCompat.getColor(getContext(), R.color.red));
        iconRoute = BitmapDescriptorFactory.fromBitmap(bitmap);
    }

    return iconRoute;
}
 
 类方法
 同包方法