/** * Scales a Bitmap to a specified float. * * @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 static BitmapDescriptor scaleIcon(Bitmap unscaledBitmap, Double scale) { int width = (int) (unscaledBitmap.getWidth() * scale); int height = (int) (unscaledBitmap.getHeight() * scale); Bitmap scaledBitmap = Bitmap.createScaledBitmap(unscaledBitmap, width, height, false); return BitmapDescriptorFactory.fromBitmap(scaledBitmap); }
public Builder<T> bitmap(Bitmap bitmap) { try { bitmapDescriptor(BitmapDescriptorFactory.fromBitmap(bitmap)); } catch (NullPointerException ignored) { // google play services is not available } return this; }
@Override protected void onBeforeClusterItemRendered(Person person, MarkerOptions markerOptions) { // Draw a single person. // Set the info window to show their name. mImageView.setImageResource(person.profilePhoto); Bitmap icon = mIconGenerator.makeIcon(); markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon)).title(person.name); }
/** * Sets the marker icon if there was a url that was found * * @param styleUrl The style which we retrieve the icon url from * @param markerOptions The marker which is displaying the icon */ private void addMarkerIcons(String styleUrl, MarkerOptions markerOptions) { if (mImagesCache.get(styleUrl) != null) { // Bitmap stored in cache Bitmap bitmap = mImagesCache.get(styleUrl); markerOptions.icon(BitmapDescriptorFactory.fromBitmap(bitmap)); } else if (!mMarkerIconUrls.contains(styleUrl)) { mMarkerIconUrls.add(styleUrl); } }
@Override protected void onBeforeClusterRendered(Cluster<Person> cluster, MarkerOptions markerOptions) { // Draw multiple people. // Note: this method runs on the UI thread. Don't spend too much time in here (like in this example). List<Drawable> profilePhotos = new ArrayList<Drawable>(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())); markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon)); }
/** * Called before the marker for a Cluster is added to the map. * The default implementation draws a circle with a rough count of the number of items. */ protected void onBeforeClusterRendered(Cluster<T> cluster, MarkerOptions markerOptions) { int bucket = getBucket(cluster); BitmapDescriptor descriptor = mIcons.get(bucket); if (descriptor == null) { mColoredCircleBackground.getPaint().setColor(getColor(bucket)); descriptor = BitmapDescriptorFactory.fromBitmap(mIconGenerator.makeIcon(getClusterText(bucket))); mIcons.put(bucket, descriptor); } // TODO: consider adding anchor(.5, .5) (Individual markers will overlap more often) markerOptions.icon(descriptor); }
/** * 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 = BitmapDescriptorFactory .fromBitmap(getImagesCache().get(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); } } }
private void addIcon(IconGenerator iconFactory, CharSequence text, LatLng position) { MarkerOptions markerOptions = new MarkerOptions(). icon(BitmapDescriptorFactory.fromBitmap(iconFactory.makeIcon(text))). position(position). anchor(iconFactory.getAnchorU(), iconFactory.getAnchorV()); getMap().addMarker(markerOptions); }
/** * 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); }
public void addOverlay(LatLng place) { GroundOverlay groundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions() .position(place, 100) .transparency(0.5f) .zIndex(3) .image(BitmapDescriptorFactory.fromBitmap(drawableToBitmap(getDrawable(R.drawable.map_overlay))))); startOverlayAnimation(groundOverlay); }
@Override protected BitmapDescriptor doInBackground(FusedContact... params) { return BitmapDescriptorFactory.fromBitmap(getBitmapFromCache(params[0])); }
/** * Scales a Bitmap to a specified float. * * @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 static BitmapDescriptor scaleIcon(Bitmap unscaledBitmap, Double scale) { int width = (int) (unscaledBitmap.getWidth() * scale); int height = (int) (unscaledBitmap.getHeight() * scale); Bitmap scaledBitmap = Bitmap.createScaledBitmap(unscaledBitmap, width, height, false); return BitmapDescriptorFactory.fromBitmap(scaledBitmap); }
@Override public BitmapDescriptor fromBitmap(Bitmap bitmap) { return new BitmapDescriptorAdapter( com.google.android.gms.maps.model.BitmapDescriptorFactory.fromBitmap(bitmap) ); }
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); }
public void addOverlay(LatLng place) { GroundOverlay groundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions() .position(place, 100) .transparency(0.5f) .zIndex(3) .image(BitmapDescriptorFactory.fromBitmap(drawableToBitmap(getActivity().getResources().getDrawable(R.drawable.map_overlay))))); startOverlayAnimation(groundOverlay); }
private void addMarkerDriverAccept(GoogleMap map, double lat, double lon, String title, String snippet) { map.addMarker(new MarkerOptions().position(new LatLng(lat, lon)) .title(title) .icon(BitmapDescriptorFactory.fromBitmap(mIconDriverAccept)) .draggable(true) .snippet(snippet)); } private void addMarkerTo(GoogleMap map, double lat, double lon,
private void myLocationMarker(LatLng latLng) { if (currentMarker != null) { currentMarker.setPosition(latLng); } else { @IdRes int icon = R.drawable.ic_navigation_red_a400_36dp; BitmapDescriptor bitmap = BitmapDescriptorFactory.fromBitmap(getBitmapFromDrawable(MapsActivity.this, icon)); currentMarker = mMap.addMarker(new MarkerOptions() .position(latLng) .icon(bitmap) .draggable(false)); } }
private void addMarkerDriver(GoogleMap map, double lat, double lon, String title, String snippet) { map.addMarker(new MarkerOptions().position(new LatLng(lat, lon)) .title(title) .icon(BitmapDescriptorFactory.fromBitmap(mIconDriver)) .draggable(true) .snippet(snippet)); } private void addMarkerDriverAccept(GoogleMap map, double lat, double lon,
private void addMarkerPenumpang( GoogleMap map, double lat, double lon, String title, String snippet) { MarkerOptions marker=new MarkerOptions().position(new LatLng(lat, lon)) .title(title) .icon(BitmapDescriptorFactory.fromBitmap(mIconPeople)) .draggable(false) .snippet(snippet); map.addMarker(marker); } private void addMarkerTo(
public void createAllMarkersInvisible() { LatLng northPoleHideout = new LatLng(90.0D, 0.0D); destMarker = map.addMarker(new MarkerOptions().position(northPoleHideout).icon(BitmapDescriptorFactory.fromBitmap(drawableDest))); destMarker.setVisible(false); currentPosition = map.addMarker(new MarkerOptions().position(northPoleHideout) .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_maps_indicator_current_position_ohne)).anchor(0.5f, 0.5f)); currentPosition.setVisible(false); current_position_anim_ohne = map.addMarker(new MarkerOptions().position(northPoleHideout) .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_maps_indicator_current_position_anim_ohne)).anchor(0.5f, 0.5f)); current_position_anim_ohne.setVisible(false); }