Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the margin color of InfoWindow view of marker in google maps api v2

Hello I try to change the default color that have (white) to black, this in the google maps api v2, anyone know how I can do this?

PD: is the margin of infowindow

screenshoot of my problem

this is my code where I change the content of infowindow but need change the margin :S

 GoogleMap map = ....
    map.setInfoWindowAdapter(new InfoWindowAdapter() {

            @Override
            public View getInfoContents(Marker marker) {
                View v = getLayoutInflater().inflate(   
                        R.layout.info_window_layout, null);
                v.setBackgroundColor(Color.BLACK);
                return v;
            }
        });

thanks for reply

like image 802
Vinicius DSL Avatar asked Aug 16 '13 21:08

Vinicius DSL


People also ask

How do I change the color of a marker in Google Maps API?

Add different color markerspng at the end of the URL to get a blue marker. To add a green marker simply change it to green-dot. png so that the URL will be http://maps.google.com/mapfiles/ms/icons/green-dot.png .

How do I change the color of a Google Marker?

To edit the marker color, click or tap on the marker icon. When you do that, you can change both the color of the marker and its style. Go for the color or style you want to change and then click OK to see the effect. Click on the button labeled Done to save your new marker color settings.

How do I change the width of infowindow on Google Maps?

maps. InfoWindow({ content: some_text, maxWidth: 200 }); The documentation notes that the "value is only considered if it is set before a call to open. To change the maximum width when changing content, call close, setOptions, and then open."


2 Answers

In InfoWindowAdapter change to

@Override
    public View getInfoWindow(Marker marker) {
        View view = ((Activity)context).getLayoutInflater()
                .inflate(R.layout.map_custom_infowindow, null);
        return view;
    }

    @Override
    public View getInfoContents(Marker marker) {

        return null;
    }
like image 52
Libin Thomas Avatar answered Sep 28 '22 05:09

Libin Thomas


Use getInfoWindow instead of getInfoContents to provide full info window. Make sure to set appropriate backgrounds for root view, e.g. something with a triangle at the bottom center.

like image 29
MaciejGórski Avatar answered Sep 28 '22 05:09

MaciejGórski