0

How can i create a custom android Marker with number in marker (1,2,3...) and with expand button in InfoWindow? As i understand first question i can solve with .icon like

 //add marker to Map
mMap.addMarker(new MarkerOptions().position(USER_POSITION)
    .icon(BitmapDescriptorFactory.fromBitmap(bmp))//my image here
    // Specifies the anchor to be at a particular point in the marker image.
    .anchor(0.5f, 1));

But what about InfoWindow? how to add to it button, that pop up big InfoWindow?

Kara
  • 6,115
  • 16
  • 50
  • 57
onCreate
  • 775
  • 3
  • 12
  • 35

1 Answers1

2

do this way it is simiple...

googleMap.setInfoWindowAdapter(new InfoWindowAdapter() {

            // Use default InfoWindow frame
            @Override
            public View getInfoWindow(Marker marker) {              
                return null;
            }           

            // Defines the contents of the InfoWindow
            @Override
            public View getInfoContents(Marker marker) {

                // Getting view from the layout file info_window_layout
                View v = getLayoutInflater().inflate(R.layout.info_window_layout, null);

                // Getting reference to the TextView to set title
                TextView note = (TextView) v.findViewById(R.id.note);

                note.setText(marker.getTitle() );

                // Returning the view containing InfoWindow contents
                return v;

            }

        });

Just add above code in your class where you are using GoogleMap. R.layout.info_window_layout is our custom layout that is showing the view that will come in place of infowindow. I just added the textview here. You can add additonal view here to make it like the sample snap. My info_window_layout was

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    >

        <TextView 
        android:id="@+id/note"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>
Hardik
  • 17,179
  • 2
  • 35
  • 40
  • Thanks, but what if i make it all in MapFragment, not in activity – onCreate Nov 21 '13 at 13:39
  • Nice, i used acticity context and all problems down. One more question, how to make InfoWindow clickable, and with click make it with more information(another layout) – onCreate Nov 21 '13 at 13:47
  • @onCreate Welcome to StackOverflow. Comments are not good for questions, but here is your answer: http://stackoverflow.com/questions/14123243/google-maps-api-v2-custom-infowindow-like-in-original-android-google-maps – MaciejGórski Nov 21 '13 at 22:36