How to show both MarkerIcon and Title in google map as like Google Apps?

后端 未结 5 1188
遇见更好的自我
遇见更好的自我 2020-12-19 03:46

When I find nearest restaurants in Google\'s Maps Android Application the restaurant name is showing near to marker icon as default. (Refer Google Image).

But in my

5条回答
  •  长情又很酷
    2020-12-19 04:16

    After few days research I finishing with this solution. We can set your own layout to IconGenerator

     View marker = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.custom_marker_layout, null);
        TextView numTxt = (TextView) marker.findViewById(R.id.num_txt);
        numTxt.setText("Naveen");
    
        final IconGenerator mIconGenerator = new IconGenerator(getApplicationContext());
        mIconGenerator.setContentView(marker);
        Bitmap icon = mIconGenerator.makeIcon();
        customMarker = mMap.addMarker(new MarkerOptions()
                .position(markerLatLng)
                .title("Title")
                .snippet("Description")
                .icon(BitmapDescriptorFactory.fromBitmap(icon))
                .anchor(0.5f, 1));
    

提交回复
热议问题