iam无法使用数据库Firebase在地图上显示标记,但是成功获取了,请帮助
我试图在maps.java中更改代码,但标记仍然无法显示
我的数据库
Maps.java
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback,LocationListener,GoogleMap.OnMarkerClickListener {
private GoogleMap mMap;
private ChildEventListener mChildEventListener;
private DatabaseReference mUploads;
Marker marker;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
SupportMapFragment mapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
ChildEventListener mChildEventListener;
mUploads = FirebaseDatabase.getInstance().getReference("uploads");
mUploads.push().setValue(marker);
}
@Override
public void onMapReady(GoogleMap googleMap){
mMap = googleMap;
googleMap.setOnMarkerClickListener(this);
googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
mUploads.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot s : dataSnapshot.getChildren()){
Upload upload = s.getValue(Upload.class);
LatLng location = new LatLng(upload.getLatitude(),upload.getLongitude());
Marker myMarker = mMap.addMarker(new MarkerOptions().position(location).title(upload.getName()));
myMarker.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW));
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
@Override
public void onLocationChanged(Location location) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public boolean onMarkerClick(Marker marker) {
return false;
}
}
我尝试更改地图中的代码[![在此处输入图片描述] [2]] [2] .java,但bu仍然无法在地图中显示