Here are the examples of the java api class com.google.android.gms.maps.model.BitmapDescriptor taken from open source projects.
1. KmlRenderer#addGroundOverlayToMap()
Project: wigle-wifi-wardriving
File: KmlRenderer.java
File: 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 = BitmapDescriptorFactory.fromBitmap(mImagesCache.get(groundOverlayUrl)); for (KmlGroundOverlay kmlGroundOverlay : groundOverlays.keySet()) { if (kmlGroundOverlay.getImageUrl().equals(groundOverlayUrl)) { GroundOverlayOptions groundOverlayOptions = kmlGroundOverlay.getGroundOverlayOptions().image(groundOverlayBitmap); GroundOverlay mapGroundOverlay = mMap.addGroundOverlay(groundOverlayOptions); if (containerVisibility == false) { mapGroundOverlay.setVisible(false); } groundOverlays.put(kmlGroundOverlay, mapGroundOverlay); } } }
2. KmlRenderer#addGroundOverlayToMap()
Project: android-maps-utils
File: KmlRenderer.java
File: 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 = BitmapDescriptorFactory.fromBitmap(mImagesCache.get(groundOverlayUrl)); for (KmlGroundOverlay kmlGroundOverlay : groundOverlays.keySet()) { if (kmlGroundOverlay.getImageUrl().equals(groundOverlayUrl)) { GroundOverlayOptions groundOverlayOptions = kmlGroundOverlay.getGroundOverlayOptions().image(groundOverlayBitmap); GroundOverlay mapGroundOverlay = mMap.addGroundOverlay(groundOverlayOptions); if (containerVisibility == false) { mapGroundOverlay.setVisible(false); } groundOverlays.put(kmlGroundOverlay, mapGroundOverlay); } } }
3. GeoJsonPointStyleTest#testIcon()
Project: wigle-wifi-wardriving
File: GeoJsonPointStyleTest.java
File: GeoJsonPointStyleTest.java
public void testIcon() throws Exception { BitmapDescriptor icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN); pointStyle.setIcon(icon); assertEquals(icon, pointStyle.getIcon()); assertEquals(icon, pointStyle.toMarkerOptions().getIcon()); }
4. KmlRenderer#scaleBitmap()
Project: wigle-wifi-wardriving
File: KmlRenderer.java
File: KmlRenderer.java
/** * Enlarges or shrinks a bitmap image based on the scale provided * @param style Style to retrieve iconUrl and scale from * @param placemark Placemark object to set the image to */ private void scaleBitmap(KmlStyle style, HashMap<KmlPlacemark, Object> placemarks, KmlPlacemark placemark) { double bitmapScale = style.getIconScale(); String bitmapUrl = style.getIconUrl(); Bitmap bitmapImage = mImagesCache.get(bitmapUrl); BitmapDescriptor scaledBitmap = scaleIcon(bitmapImage, bitmapScale); ((Marker) placemarks.get(placemark)).setIcon(scaledBitmap); }
5. DefaultClusterRenderer#onBeforeClusterRendered()
Project: wigle-wifi-wardriving
File: DefaultClusterRenderer.java
File: DefaultClusterRenderer.java
/** * 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); }
6. MapUtils#createMosconeMarker()
Project: iosched
File: MapUtils.java
File: MapUtils.java
/** * Creates a marker for Moscone Center. */ public static MarkerOptions createMosconeMarker(LatLng position) { final String title = "MOSCONE"; final BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.map_marker_moscone); return new MarkerOptions().position(position).title(title).icon(icon).visible(false); }
7. MapUtils#createLabelMarker()
Project: iosched
File: MapUtils.java
File: MapUtils.java
/** * 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); }
8. MapUtils#createPinMarker()
Project: iosched
File: MapUtils.java
File: MapUtils.java
/** * Creates a marker for a session. * * @param id Id to be embedded as the title */ public static MarkerOptions createPinMarker(String id, LatLng position) { final BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.map_marker_unselected); return new MarkerOptions().position(position).title(id).icon(icon).anchor(0.5f, 0.85526f).visible(false); }
9. GeoJsonPointStyleTest#testIcon()
Project: android-maps-utils
File: GeoJsonPointStyleTest.java
File: GeoJsonPointStyleTest.java
public void testIcon() throws Exception { BitmapDescriptor icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN); pointStyle.setIcon(icon); assertEquals(icon, pointStyle.getIcon()); assertEquals(icon, pointStyle.toMarkerOptions().getIcon()); }
10. KmlRenderer#scaleBitmap()
Project: android-maps-utils
File: KmlRenderer.java
File: KmlRenderer.java
/** * Enlarges or shrinks a bitmap image based on the scale provided * @param style Style to retrieve iconUrl and scale from * @param placemark Placemark object to set the image to */ private void scaleBitmap(KmlStyle style, HashMap<KmlPlacemark, Object> placemarks, KmlPlacemark placemark) { double bitmapScale = style.getIconScale(); String bitmapUrl = style.getIconUrl(); Bitmap bitmapImage = mImagesCache.get(bitmapUrl); BitmapDescriptor scaledBitmap = scaleIcon(bitmapImage, bitmapScale); ((Marker) placemarks.get(placemark)).setIcon(scaledBitmap); }
11. DefaultClusterRenderer#onBeforeClusterRendered()
Project: android-maps-utils
File: DefaultClusterRenderer.java
File: DefaultClusterRenderer.java
/** * 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); }