2014-01-23 47 views
2

我们可以在我的位置蓝色圆点上显示自定义信息窗口。 这是我的地图class.I通过扩展SupportMapFragment我的位置上的自定义信息窗口

代码创建的地图:

public class MapFragment extends SupportMapFragment { 

GoogleMap mapView; 
private Context context; 

@Override 
public void onCreate(Bundle arg0) { 
    super.onCreate(arg0); 
} 



@Override 
public View onCreateView(LayoutInflater mInflater, ViewGroup arg1, 
     Bundle arg2) { 
    View view = super.onCreateView(mInflater, arg1, arg2); 
     setMapTransparent((ViewGroup) view); 
     return view; 
} 

回答

0

你们班延长

OnMarkerClickListener 

和覆盖此函数

public boolean onMarkerClick(Marker arg0) { 
      // TODO Auto-generated method stub 

      arg0.showInfoWindow(); 
      return true; 
     } 

您可以通过使用功能的回答

mMap.setInfoWindowAdapter(new BalloonAdapter(getLayoutInflater())); 


public class BalloonAdapter implements InfoWindowAdapter { 
    LayoutInflater inflater = null; 
    private TextView textViewTitle; 

    public BalloonAdapter(LayoutInflater inflater) { 
     this.inflater = inflater; 
    } 


    public View getInfoWindow(Marker marker) { 
     View v = inflater.inflate(R.layout.balloon, null); 
     if (marker != null) { 
      textViewTitle = (TextView) v.findViewById(R.id.textViewTitle); 
      textViewTitle.setText(marker.getTitle()); 
     } 
     return (v); 
    } 


    public View getInfoContents(Marker marker) { 
     return (null); 
    } 
} 
+0

由于定制的信息窗口,但我想显示在我的位置信息窗口即蓝点(setMyLocationenabled(true))而不是标记。 –

+0

尝试使用谷歌地图这个回调事件GoogleMap.OnMyLocationButtonClickListener –

+0

检查此答案http://stackoverflow.com/questions/18141082/override-mylocation-button-in-android-google-maps-api-v2 –

相关问题