com.google.android.gms.maps.model.BitmapDescriptor Java Examples
The following examples show how to use
com.google.android.gms.maps.model.BitmapDescriptor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Renderer.java From android-maps-utils with Apache License 2.0 | 6 votes |
/** * 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; }
Example #2
Source File: GglMapAiLineManager.java From FimiX8-RE with MIT License | 6 votes |
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; }
Example #3
Source File: GglMapAiLineManager.java From FimiX8-RE with MIT License | 6 votes |
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; }
Example #4
Source File: EmergencyInteractorImpl.java From Saude-no-Mapa with MIT License | 6 votes |
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; }
Example #5
Source File: GglMapAiLineManager.java From FimiX8-RE with MIT License | 6 votes |
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); }
Example #6
Source File: MapMarker.java From android-app with GNU General Public License v2.0 | 6 votes |
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; }
Example #7
Source File: GglMapAiLineManager.java From FimiX8-RE with MIT License | 6 votes |
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()); } }
Example #8
Source File: GeoJsonDemoActivity.java From android-maps-utils with Apache License 2.0 | 6 votes |
/** * 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); } } }
Example #9
Source File: CustomMarkerClusteringDemoActivity.java From android-maps-utils with Apache License 2.0 | 6 votes |
/** * 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); }
Example #10
Source File: MarkerIconFactory.java From ground-android with Apache License 2.0 | 6 votes |
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); }
Example #11
Source File: Renderer.java From android-maps-utils with Apache License 2.0 | 6 votes |
/** * 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); }
Example #12
Source File: EstablishmentInteractorImpl.java From Saude-no-Mapa with MIT License | 6 votes |
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; }
Example #13
Source File: ViewUtils.java From animation-samples with Apache License 2.0 | 6 votes |
/** * 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; }
Example #14
Source File: KmlRenderer.java From android-maps-utils with Apache License 2.0 | 6 votes |
/** * 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); } } }
Example #15
Source File: DefaultIconGenerator.java From google-maps-clustering with Apache License 2.0 | 6 votes |
@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); }
Example #16
Source File: GeoJsonPointStyleTest.java From android-maps-utils with Apache License 2.0 | 5 votes |
@Ignore("I should run via Robolectric - java.lang.NullPointerException: IBitmapDescriptorFactory is not initialized") // FIXME @Test public void testIcon() { if (TestUtil.isRunningOnTravis()) { Assume.assumeTrue("Skipping GeoJsonPointStyleTest.testIcon() - this is expected behavior on Travis CI (#573)", false); return; } BitmapDescriptor icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN); pointStyle.setIcon(icon); assertEquals(icon, pointStyle.getIcon()); assertEquals(icon, pointStyle.toMarkerOptions().getIcon()); }
Example #17
Source File: Renderer.java From android-maps-utils with Apache License 2.0 | 5 votes |
/** * Sets the marker icon if there is a cached image for the URL, * otherwise adds the URL to set to download images * * @param styleUrl the icon url from * @param scale the icon scale * @param markerOptions marker options to set icon on */ private void addMarkerIcons(String styleUrl, double scale, MarkerOptions markerOptions) { // BitmapDescriptor stored in cache BitmapDescriptor bitmap = getCachedMarkerImage(styleUrl, scale); if (bitmap != null) { markerOptions.icon(bitmap); } else { mMarkerIconUrls.add(styleUrl); } }
Example #18
Source File: KmlRenderer.java From android-maps-utils with Apache License 2.0 | 5 votes |
/** * Enlarges or shrinks a bitmap image based on the scale provided * * @param style Style to retrieve iconUrl and scale from * @param marker Marker to set the image to */ private void scaleBitmap(KmlStyle style, Marker marker) { double bitmapScale = style.getIconScale(); String bitmapUrl = style.getIconUrl(); BitmapDescriptor scaledBitmap = getCachedMarkerImage(bitmapUrl, bitmapScale); marker.setIcon(scaledBitmap); }
Example #19
Source File: IconMarker.java From android-custom-markers with Apache License 2.0 | 5 votes |
@Override public BitmapDescriptor getBitmapDescriptor() { return BitmapDescriptorFactory.fromResource( selectedIcon > 0 && isSelected() ? selectedIcon : defaultIcon ); }
Example #20
Source File: DefaultClusterRenderer.java From android-maps-utils with Apache License 2.0 | 5 votes |
/** * Gets a BitmapDescriptor for the given cluster that contains a rough count of the number of * items. Used to set the cluster marker icon in the default implementations of * {@link #onBeforeClusterRendered(Cluster, MarkerOptions)} and * {@link #onClusterUpdated(Cluster, Marker)}. * * @param cluster cluster to get BitmapDescriptor for * @return a BitmapDescriptor for the marker icon for the given cluster that contains a rough * count of the number of items. */ @NonNull protected BitmapDescriptor getDescriptorForCluster(@NonNull Cluster<T> cluster) { 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); } return descriptor; }
Example #21
Source File: MainActivity.java From ExamplesAndroid with Apache License 2.0 | 5 votes |
@Override protected void onBeforeClusterItemRendered(MyItem item, MarkerOptions markerOptions) { BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.mipmap.davidhackro); markerOptions.icon(icon); markerOptions.snippet(item.getTitle()); markerOptions.title(item.getSubtitle()); markerOptions.position(item.getPosition()); super.onBeforeClusterItemRendered(item, markerOptions); }
Example #22
Source File: MarkerDemoActivity.java From android-samples with Apache License 2.0 | 5 votes |
/** * 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); }
Example #23
Source File: ClusterRenderer.java From google-maps-clustering with Apache License 2.0 | 5 votes |
@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); }
Example #24
Source File: ToastedMarkerOptionsChooser.java From clusterkraf with Apache License 2.0 | 5 votes |
@Override public void choose(MarkerOptions markerOptions, ClusterPoint clusterPoint) { Context context = contextRef.get(); if (context != null) { Resources res = context.getResources(); boolean isCluster = clusterPoint.size() > 1; boolean hasTwoToasters = clusterPoint.containsInputPoint(twoToasters); BitmapDescriptor icon; String title; if (isCluster) { title = res.getQuantityString(R.plurals.count_points, clusterPoint.size(), clusterPoint.size()); int clusterSize = clusterPoint.size(); if (hasTwoToasters) { icon = BitmapDescriptorFactory.fromBitmap(getClusterBitmap(res, R.drawable.ic_map_pin_cluster_toaster, clusterSize)); title = res.getString(R.string.including_two_toasters, title); } else { icon = BitmapDescriptorFactory.fromBitmap(getClusterBitmap(res, R.drawable.ic_map_pin_cluster, clusterSize)); title = res.getQuantityString(R.plurals.count_points, clusterSize, clusterSize); } } else { MarkerData data = (MarkerData)clusterPoint.getPointAtOffset(0).getTag(); if (hasTwoToasters) { icon = BitmapDescriptorFactory.fromResource(R.drawable.ic_map_pin_toaster); title = data.getLabel(); } else { icon = BitmapDescriptorFactory.fromResource(R.drawable.ic_map_pin); title = res.getString(R.string.point_number_x, data.getLabel()); } } markerOptions.icon(icon); markerOptions.title(title); markerOptions.anchor(0.5f, 1.0f); } }
Example #25
Source File: Renderer.java From android-maps-utils with Apache License 2.0 | 5 votes |
/** * Cache the scaled BitmapDescriptor for the URL * * @param url URL image was loaded from * @param scale scale the image was scaled to as a formatted string for the cache * @param bitmapDescriptor BitmapDescriptor to cache for reuse */ private void putMarkerImagesCache(String url, String scale, BitmapDescriptor bitmapDescriptor) { Map<String, BitmapDescriptor> bitmaps = mImagesCache.markerImagesCache.get(url); if (bitmaps == null) { bitmaps = new HashMap<>(); mImagesCache.markerImagesCache.put(url, bitmaps); } bitmaps.put(scale, bitmapDescriptor); }
Example #26
Source File: MainActivity.java From AndroidLocationStarterKit with MIT License | 5 votes |
private void drawMalMarkers(ArrayList<Location> locationList, BitmapDescriptor descriptor){ for(Location location : locationList){ LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); Marker marker = map.addMarker(new MarkerOptions() .position(latLng) .flat(true) .anchor(0.5f, 0.5f) .icon(descriptor)); malMarkers.add(marker); } }
Example #27
Source File: GglMapCustomMarkerView.java From FimiX8-RE with MIT License | 5 votes |
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)); }
Example #28
Source File: PlaceMapFragment.java From RxGpsService with Apache License 2.0 | 5 votes |
private BitmapDescriptor getIconUser() { if (iconUser == null) { Bitmap bitmap = bitmapHelper.getBitmap(getContext(), R.drawable.ic_accessibility); bitmap = bitmapHelper.getTintedBitmap(bitmap, ContextCompat.getColor(getContext(), R.color.green)); iconUser = BitmapDescriptorFactory.fromBitmap(bitmap); } return iconUser; }
Example #29
Source File: PlaceMapFragment.java From RxGpsService with Apache License 2.0 | 5 votes |
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; }
Example #30
Source File: PlaceMapFragment.java From RxGpsService with Apache License 2.0 | 5 votes |
private BitmapDescriptor getIconPoi() { if (iconPoi == null) { Bitmap bitmap = bitmapHelper.getBitmap(getContext(), R.drawable.ic_place); bitmap = bitmapHelper.getTintedBitmap(bitmap, ContextCompat.getColor(getContext(), R.color.orange)); iconPoi = BitmapDescriptorFactory.fromBitmap(bitmap); } return iconPoi; }