Custom infowindow with google maps api v2

后端 未结 4 1100
青春惊慌失措
青春惊慌失措 2020-12-10 15:04

I can customize the content of the infoWindow with a simple block of code:

 private GoogleMap mMap;
 mMap.setInfoWindowAdapter(new InfoWindowAdapter() {

            


        
4条回答
  •  佛祖请我去吃肉
    2020-12-10 15:16

    you have to write your code in getInfoWindow method. so you can customize info window. e.g.

    @Override
    public View getInfoWindow(Marker marker) {
    
        // Getting view from the layout file
        View v = inflater.inflate(R.layout.map_popup, null);
    
        TextView title = (TextView) v.findViewById(R.id.title);
        title.setText(marker.getTitle());
    
        TextView address = (TextView) v.findViewById(R.id.distance);
        address.setText(marker.getSnippet());
    
        return v;
    }
    
    @Override
    public View getInfoContents(Marker arg0) {
        // TODO Auto-generated method stub
        return null;
    }
    

提交回复
热议问题