我不想更改标记的图像 我只想在标题中添加一个图像,以便它看起来不错
像这样的“阅读更多”图片..
有没有办法呢
感谢
答案 0 :(得分:1)
标题称为InfoWindow
。要实现自定义窗口,您需要:
1)创建实现GoogleMap.InfoWindowAdapter
接口的类。像这样的东西(在这种情况下只是TextView
):
public class MapItemAdapter implements GoogleMap.InfoWindowAdapter {
TextView tv;
public MapItemAdapter(Context context) {
tv = new TextView(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
tv.setLayoutParams(lp);
tv.setGravity(Gravity.CENTER);
}
@Override
public View getInfoWindow(Marker marker) {
tv.setText(marker.getTitle());
return tv;
}
@Override
public View getInfoContents(Marker marker) {
return null;
}
}
2)将适配器设置为您在GoogleMap
回调中收到的onMapReady()
:
@Override
public void onMapReady(final GoogleMap map) {
...
map.setInfoWindowAdapter(new MapItemAdapter(this));
...
}