【发布时间】:2017-02-07 17:52:32
【问题描述】:
您好,我正在使用谷歌地图,我在我拥有的标记上创建了一个自定义标题,我需要知道何时选择了标记我如何获取标题上的信息,因为我需要打开一个片段有了这些信息,让我把我得到的代码贴给你吧:
@Override
public void onMapReady(GoogleMap googleMap) {
map =googleMap;
map.getUiSettings().setZoomControlsEnabled(true);
for (Taxi taxi : taxis) {
u= taxi.getUbicacionActual();
LatLng ubicacion= new LatLng(Double.parseDouble(u.getLatitud()), Double.parseDouble(u.getLongitud()));
map.moveCamera(CameraUpdateFactory.newLatLngZoom(ubicacion,15));
MarkerOptions punto= new MarkerOptions().position(ubicacion);
map.addMarker(punto);
map.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker marker) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
View v = getLayoutInflater().inflate(R.layout.info_title, null);
TextView info1 = (TextView) v.findViewById(R.id.info1);
TextView info2 = (TextView) v.findViewById(R.id.info2);
TextView info3 = (TextView) v.findViewById(R.id.info3);
info1.setText("Fecha: " + u.getFecha());
info3.setText("Longitud: " + u.getLongitud().toString());
info2.setText("Ubicacion: "+obtenerDireccion(u.getLatitud(),u.getLongitud()));
return v;
}
});
}
map.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
Fragment fragmento;
fragmento = new HistorialFragment();
getSupportFragmentManager().beginTransaction()
.replace(R.id.content_principal, fragmento)
.commit();
}
});
在我调用新片段的方法 OnInfoWindowClickListener 上,我需要从自定义标题发送信息,有人可以帮我吗?
【问题讨论】: