在我的应用中,我必须在位置上显示有关标记的信息。 这是我的工作代码。
mPerth = mMap.addMarker(new MarkerOptions()
.position(PERTH)
.title("Perth")
.snippet("Population: Perth")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE)));
mPerth.showInfoWindow();
答案 0 :(得分:0)
尝试一下。
marker.setInfoWindowAnchor(1f,1f)
编辑:
对于自定义infoWindow,您必须具体实现 GoogleMap.InfoWindowAdapter ,并在getInfoWindow(Marker marker)方法中添加 custom_info_window_layout.xml 文件。
>public class CustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {
Activity context;
CustomInfoWindow(Activity context){
this.context =context;
}
@Override
public View getInfoWindow(Marker marker) {
View view = context.getLayoutInflater().inflate(R.layout.custom_info_window_layout, null);
TextView title =(TextView) view.findViewById(R.id.tv_title);
TextView snippet =(TextView) view.findViewById(R.id.tv_snippet);
title.setText(marker.getTitle());
snippet.setText(marker.getSnippet());
return view;
}
@Override
public View getInfoContents(Marker marker) {
return null;
}
}
最后在地图上设置此 CustomInfoWindowAdapter 。
map.setInfoWindowAdapter(new CustomInfoWindowAdapter(MainActivity.this))
答案 1 :(得分:0)