您可以创建自定义标记并在其中添加详细信息。
您可以在标题传递信息或只是片断,并在您的自定义标记使用
mapView.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
// Use default InfoWindow frame
@Override
public View getInfoWindow(Marker arg0) {
return null;
}
// Defines the contents of the InfoWindow
@Override
public View getInfoContents(Marker arg0) {
// Getting view from the layout file info_window_layout
View v = getActivity().getLayoutInflater().inflate(R.layout.layout_mapinfo, null); // my custom view
// Getting the position from the marker
// LatLng latLng = arg0.getPosition();
// Getting reference to the TextView to set latitude
TextView tvLat = (TextView) v.findViewById(R.id.tv_lat);
// Getting reference to the TextView to set longitude
TextView tvLng = (TextView) v.findViewById(R.id.tv_lng);
// Setting the latitude
tvLat.setText(arg0.getTitle());
// Setting the longitude
AppSession.setIconTypeface(tvLng);
tvLng.setText(Html.fromHtml(arg0.getSnippet()));
// Returning the view containing InfoWindow contents
return v;
}
});
layout_mapinfo.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<TextView
android:id="@+id/tv_lat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:gravity="center_horizontal"
/>
<TextView
android:id="@+id/tv_lng"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:layout_gravity="center"
android:gravity="center"
/>
</LinearLayout>
如何在标题传递价值和摘要,以及如何interprete它在您的自定义视图中取决于您的要求。
希望这会有所帮助。
注意:此代码段仅用于示例目的。
你真正想要哪种类型的属性? –