if (googleMap != null && mapFragment != null && googleMap.getProjection() != null) {
googleMap.addMarker(new MarkerOptions().position(new LatLng(
Double.parseDouble(storesWithDistance.getLatitude() + ""), Double.parseDouble(storesWithDistance.getLongitude() + "")
)).title(storesWithDistance.getStoreName() + "").snippet(i + ""));
}
`marker.getTitle()` is returning `null` ..... Why is it happening ?
@Override
public boolean onMarkerClick(Marker marker) {
try {
if (googleMap != null && mapFragment != null && googleMap.getProjection() != null) {
String title = marker.getTitle();
String snippet = marker.getSnippet();
Log.d("","");
}
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
答案 0 :(得分:1)
您是否实现了 GoogleMap.OnMarkerClickListener 接口? 您是否添加了这一行? :
googleMap.setOnMarkerClickListener(this)
如果您尝试将String title = marker.getTitle();
从 try..catch 块中取出并用Log.d()测试,该怎么办?