Reputation: 43
How to get customize markers with Imageview and Textview for google map v2 for android
Please refer to the attached image for better understanding:
Upvotes: 3
Views: 4174
Reputation: 17083
Create a view using XML
<FrameLayout
android:id="@+id/framelayout"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<ImageView
android:id="@+id/ImageView01"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
<TextView android:id="@+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>
Get the view and set your values
FrameLayout view = (FrameLayout)findViewById(R.id.framelayout);
Generate a bitmap
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bm = view.getDrawingCache();
use this bitmap as your marker
Marker myMarker = mMap.addMarker(new MarkerOptions()
.position(0,0)
.icon(BitmapDescriptorFactory.fromBitmap(mybitmap)));
Upvotes: 2