public Builder<T> bitmapDescriptor(BitmapDescriptor bitmap) { markerOptions.icon(bitmap); return this; }
/** * Sets a bitmap image for the GeoJsonPoint * * @param bitmap bitmap descriptor for the GeoJsonPoint */ public void setIcon(BitmapDescriptor bitmap) { mMarkerOptions.icon(bitmap); styleChanged(); }
public Builder<T> iconId(int iconId) { try { markerOptions.icon(BitmapDescriptorFactory.fromResource(iconId)); } catch (NullPointerException ignored) { // google play services is not available } return this; }
/** * Sets the color for a marker * * @param color Color for a marker */ /* package */ void setMarkerColor(String color) { int integerColor = Color.parseColor("#" + convertColor(color)); mMarkerColor = getHueValue(integerColor); mMarkerOptions.icon(BitmapDescriptorFactory.defaultMarker(mMarkerColor)); mStylesSet.add("markerColor"); }
@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); }
/** * Creates a new marker option from given properties of an existing marker option * * @param originalMarkerOption An existing MarkerOption instance * @param iconRandomColorMode True if marker color mode is random, false otherwise * @param markerColor Color of the marker * @return A new MarkerOption */ private static MarkerOptions createMarkerOptions(MarkerOptions originalMarkerOption, boolean iconRandomColorMode, float markerColor) { MarkerOptions newMarkerOption = new MarkerOptions(); newMarkerOption.rotation(originalMarkerOption.getRotation()); newMarkerOption.anchor(originalMarkerOption.getAnchorU(), originalMarkerOption.getAnchorV()); if (iconRandomColorMode) { float hue = getHueValue(computeRandomColor((int) markerColor)); originalMarkerOption.icon(BitmapDescriptorFactory.defaultMarker(hue)); } newMarkerOption.icon(originalMarkerOption.getIcon()); return newMarkerOption; }
private void addMarker(GoogleMap map, double lat, double lon, int title, int snippet, int hue) { map.addMarker(new MarkerOptions().position(new LatLng(lat, lon)) .title(getString(title)) .snippet(getString(snippet)) .icon(BitmapDescriptorFactory.defaultMarker(hue))); } }
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); }
private void placeMarkers() { // Add a marker for every earthquake for (EarthQuakeRec rec : mRetainedFragment.getData()) { // Add a new marker for this earthquake mMap.addMarker(new MarkerOptions() // Set the Marker's position .position(new LatLng(rec.getLat(), rec.getLng())) // Set the title of the Marker's information window .title(String.valueOf(rec.getMagnitude())) // Set the color for the Marker .icon(BitmapDescriptorFactory .defaultMarker(getMarkerColor(rec .getMagnitude())))); } }
/** * Sets the inline point style by copying over the styles that have been set * * @param markerOptions marker options object to add inline styles to * @param inlineStyle inline styles to apply * @param markerUrlIconUrl default marker icon URL from shared style */ private void setInlinePointStyle(MarkerOptions markerOptions, KmlStyle inlineStyle, String markerUrlIconUrl) { MarkerOptions inlineMarkerOptions = inlineStyle.getMarkerOptions(); if (inlineStyle.isStyleSet("heading")) { markerOptions.rotation(inlineMarkerOptions.getRotation()); } if (inlineStyle.isStyleSet("hotSpot")) { markerOptions .anchor(inlineMarkerOptions.getAnchorU(), inlineMarkerOptions.getAnchorV()); } if (inlineStyle.isStyleSet("markerColor")) { markerOptions.icon(inlineMarkerOptions.getIcon()); } if (inlineStyle.isStyleSet("iconUrl")) { addMarkerIcons(inlineStyle.getIconUrl(), markerOptions); } else if (markerUrlIconUrl != null) { // Inline style with no icon defined addMarkerIcons(markerUrlIconUrl, markerOptions); } }
/** * Gets a new MarkerOptions object containing styles for the GeoJsonPoint * * @return new MarkerOptions object */ public MarkerOptions toMarkerOptions() { MarkerOptions markerOptions = new MarkerOptions(); markerOptions.alpha(mMarkerOptions.getAlpha()); markerOptions.anchor(mMarkerOptions.getAnchorU(), mMarkerOptions.getAnchorV()); markerOptions.draggable(mMarkerOptions.isDraggable()); markerOptions.flat(mMarkerOptions.isFlat()); markerOptions.icon(mMarkerOptions.getIcon()); markerOptions.infoWindowAnchor(mMarkerOptions.getInfoWindowAnchorU(), mMarkerOptions.getInfoWindowAnchorV()); markerOptions.rotation(mMarkerOptions.getRotation()); markerOptions.snippet(mMarkerOptions.getSnippet()); markerOptions.title(mMarkerOptions.getTitle()); markerOptions.visible(mMarkerOptions.isVisible()); markerOptions.zIndex(mMarkerOptions.getZIndex()); return markerOptions; }
private void addMarker(LatLng destination) { MarkerOptions options = new MarkerOptions(); options.position(destination); options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); mMap.addMarker(options); }
@Override public void onMapReady(GoogleMap map) { map.setOnMarkerDragListener(SplitStreetViewPanoramaAndMapDemoActivity.this); // Creates a draggable marker. Long press to drag. mMarker = map.addMarker(new MarkerOptions() .position(markerPosition) .icon(BitmapDescriptorFactory.fromResource(R.drawable.pegman)) .draggable(true)); } });
/** * Add Markers with default info windows to the map. */ private void addMarkers() { mMap.addMarker(new MarkerOptions() .position(BRISBANE) .title("Brisbane")); mMap.addMarker(new MarkerOptions() .position(MELBOURNE) .title("Melbourne") .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))); mMap.addMarker(new MarkerOptions() .position(SYDNEY) .title("Sydney") .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED))); mMap.addMarker(new MarkerOptions() .position(ADELAIDE) .title("Adelaide") .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW))); mMap.addMarker(new MarkerOptions() .position(PERTH) .title("Perth") .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA))); } }
@Override public void onMapReady(GoogleMap map) { MarkerOptions markerOptions = new MarkerOptions() .position(mMarkerPosition) .icon(BitmapDescriptorFactory.defaultMarker(mMarkerInfo.mHue)) .draggable(true); map.addMarker(markerOptions); map.setOnMarkerDragListener(this); map.setOnMarkerClickListener(this); if (mMoveCameraToMarker) { map.animateCamera(CameraUpdateFactory.newLatLng(mMarkerPosition)); } }
public DraggableCircle(LatLng center, double radiusMeters) { mRadiusMeters = radiusMeters; mCenterMarker = mMap.addMarker(new MarkerOptions() .position(center) .draggable(true)); mRadiusMarker = mMap.addMarker(new MarkerOptions() .position(toRadiusLatLng(center, radiusMeters)) .draggable(true) .icon(BitmapDescriptorFactory.defaultMarker( BitmapDescriptorFactory.HUE_AZURE))); mCircle = mMap.addCircle(new CircleOptions() .center(center) .radius(radiusMeters) .strokeWidth(mStrokeWidthBar.getProgress()) .strokeColor(mStrokeColorArgb) .fillColor(mFillColorArgb) .clickable(mClickabilityCheckbox.isChecked())); }
.title("Brisbane") .snippet("Population: 2,074,200") .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))); .title("Sydney") .snippet("Population: 4,627,300") .icon(BitmapDescriptorFactory.fromResource(R.drawable.arrow)) .infoWindowAnchor(0.5f, 0.5f)); .icon(vectorToBitmap(R.drawable.ic_android, Color.parseColor("#A4C639"))) .title("Alice Springs")); 135 - 10 * Math.cos(i * Math.PI / (numMarkersInRainbow - 1)))) .title("Marker " + i) .icon(BitmapDescriptorFactory.defaultMarker(i * 360 / numMarkersInRainbow)) .flat(flat) .rotation(rotation));