Android-maps-utils: Marker with Label

Created on 28 Dec 2017  路  2Comments  路  Source: googlemaps/android-maps-utils

Hi,I searched a lot but i couldnt find. Is there any way to put label above/below marker like this?
Thanks.

markerwithlabel

Most helpful comment

You can create Bitmap and set it to marker

   public Bitmap getMarkerIconWithLabel(String label, float angle) {
        IconGenerator iconGenerator = new IconGenerator(mContext);
        View markerView = LayoutInflater.from(mContext).inflate(R.layout.lay_marker, null);
        ImageView imgMarker = markerView.findViewById(R.id.img_marker);
        TextView tvLabel = markerView.findViewById(R.id.tv_label);
        imgMarker.setImageResource(R.drawable.marker);
        imgMarker.setRotation(angle);
        tvLabel.setText(label);
        iconGenerator.setContentView(markerView);
        iconGenerator.setBackground(null);
        return iconGenerator.makeIcon(label);
    }

@Override protected void onBeforeClusterItemRendered(LiveTrackingModel item, MarkerOptions markerOptions) { super.onBeforeClusterItemRendered(item, markerOptions); markerOptions.icon(BitmapDescriptorFactory.fromBitmap(getMarkerIconWithLabel("Marker1",26.6))) }

All 2 comments

You can create Bitmap and set it to marker

   public Bitmap getMarkerIconWithLabel(String label, float angle) {
        IconGenerator iconGenerator = new IconGenerator(mContext);
        View markerView = LayoutInflater.from(mContext).inflate(R.layout.lay_marker, null);
        ImageView imgMarker = markerView.findViewById(R.id.img_marker);
        TextView tvLabel = markerView.findViewById(R.id.tv_label);
        imgMarker.setImageResource(R.drawable.marker);
        imgMarker.setRotation(angle);
        tvLabel.setText(label);
        iconGenerator.setContentView(markerView);
        iconGenerator.setBackground(null);
        return iconGenerator.makeIcon(label);
    }

@Override protected void onBeforeClusterItemRendered(LiveTrackingModel item, MarkerOptions markerOptions) { super.onBeforeClusterItemRendered(item, markerOptions); markerOptions.icon(BitmapDescriptorFactory.fromBitmap(getMarkerIconWithLabel("Marker1",26.6))) }

Thank you Kintanpatel4393, this is exactly what I'm looking for.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mengoni picture mengoni  路  4Comments

vardaan picture vardaan  路  6Comments

TatyanaRTB picture TatyanaRTB  路  3Comments

leicht-io picture leicht-io  路  6Comments

lschlessinger1 picture lschlessinger1  路  6Comments