【发布时间】:2018-01-25 09:32:36
【问题描述】:
我正在调用 createMarker,它会在循环运行后动态添加数据。我正在使用 InfoWindowAdapter 添加标记选项。但是我有问题,当我单击带有 infoContent 的标记时它不会改变。
这是我添加标记选项的方法..
public MarkerOptions createMarker(final String Date, final String Time, final String Location, final String Engine,final String Remarks, Double latitude, final Double longitude, final String Plate_num) {
System.out.println(Location + " lLocation");
mMapFragment.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker marker) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
View v = getActivity().getLayoutInflater().inflate(R.layout.custom_info_contents_vehicle_map, null);
TextView plate_nu = (TextView) v.findViewById(R.id.plate_num);
TextView dat = (TextView) v.findViewById(R.id.date);
TextView tim = (TextView) v.findViewById(R.id.time);
TextView loc = (TextView) v.findViewById(R.id.location);
TextView engin = (TextView) v.findViewById(engine);
TextView remark = (TextView) v.findViewById(R.id.rema);
plate_nu.setText(Plate_num);
dat.setText(Date);
tim.setText(Time);
loc.setText(Location);
engin.setText(Engine);
remark.setText(Remarks);
return v;
}
});
return new MarkerOptions()
.position(new LatLng(latitude, longitude))
.title("Plate No.")
.snippet(Plate_num)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
}
我正在使用系统输出来输出位置,它确实发生了变化。但是,问题所在的信息内容内部。我没有看到任何更改,或者如何使用上面的代码更改我的InfoWindowAdapter 数据??
【问题讨论】:
-
试试这个 // 从片段中获取 GoogleMap 对象 googleMap = mapFragment.getMap(); // 为谷歌地图设置自定义信息窗口适配器 googleMap.setInfoWindowAdapter(new InfoWindowAdapter() {
标签: android google-maps-markers infowindow