0

In my android app, I have a info window for a marker I place on the map. I want to do these things:

  1. Make the default marker bigger (its too small now)
  2. When the info window shows up, the text in it is making the width too long. Is there a way I can set a maximum width on it?
  3. How can I increase the font size for the title and text?

Can anyone show me how to do this?

Thanks.

omega
  • 40,311
  • 81
  • 251
  • 474
  • check this [earlier post](http://stackoverflow.com/questions/17391445/multiple-line-or-break-line-in-snippet-google-maps-apiv2/17393978#17393978) – tony m Aug 05 '13 at 03:55

2 Answers2

1

Maybe a little late, but you need to create a new custom adapter you can take a look in here: How to change Google Maps marker window Info

 mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {

        @Override
        public View getInfoWindow(com.google.android.gms.maps.model.Marker arg0) {
            return null;
        }

        @Override
        public View getInfoContents(com.google.android.gms.maps.model.Marker marker) {
            LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService
                    (Context.LAYOUT_INFLATER_SERVICE);
            View mView = null;
            //using the id, you can store multiple types of markers on List's and change the layout
            if (marker.getId().equals(end.getId())) {
                mView = inflater.inflate(R.layout.custom_info_window, (ViewGroup) findViewById(R.id.map), false);
                ((TextView) mView.findViewById(R.id.txtTitle)).setText(marker.getTitle());
            }else{
                mView = inflater.inflate(R.layout.normal_info_window, (ViewGroup) findViewById(R.id.map), false);
                ((TextView) mView.findViewById(R.id.txtTitle)).setText(marker.getTitle());
                ((TextView) mView.findViewById(R.id.txtDescription)).setText(marker.getSnippet());
            }
            return mView;
        }
    });
    mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
        @Override
        public void onInfoWindowClick(Marker marker) {
                 //do whatever you need
        }
    });

In te custom view you can modify the size of the font, and other things, for the first point the marker icon can be modified on the MarkerOptions.setIcon, where you can use one from your assets.

Rodolfo Abarca
  • 565
  • 7
  • 15
0

1: When you add the Marker to the map, you can set the icon in the MarkerOptions. Make your own icon and use that.

2 & 3: Set an onMarkerClickListener on your GoogleMap. In the callback, you can create and show your own info window view on the map (just make sure you return false from the onMarkerClick() callback)

Karakuri
  • 38,365
  • 12
  • 84
  • 104
  • How do I create my own info window? – omega Aug 05 '13 at 02:56
  • Well, I presume you would make or inflate a layout and add it to the screen programmatically. The MapView returned by `getMap()` extends FrameLayout, so you can create FrameLayout.LayoutParams for your info window and add it to the MapView directly. You may have to play around with moving the map and calculating the position of the window. – Karakuri Aug 05 '13 at 03:02