我已经在一个片段中实现了Google地图,但是它没有从Firebase数据库加载纬度和经度。我
我的addListenerForSignleValueEvent无法正常工作。
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
googleMap .setOnMarkerClickListener(this);
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
mUsers.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for(DataSnapshot s:dataSnapshot.getChildren()){
Post2 user= s.getValue(Post2.class);
LatLng location = new LatLng(user.latitude,user.longtitude);
mMap.addMarker(new MarkerOptions().position(location).title(user.placename)).setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ROSE));
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
private void showMessage(String message) {
Toast.makeText(this,message,Toast.LENGTH_LONG).show();
}
@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;
}
}
////////////列表///////
2019-07-18 21:12:07.421 2022-2435 / system_process I / GnssLocationProvider:sendMessage获取的WakeLock(REPORT_SV_STATUS,0,com.android.server.location.GnssLocationProvider$SvStatusInfo@5743010)
2019-07-18 21:12:07.421 2022-2040 / system_process I / GnssLocationProvider:WakeLock由handleMessage(REPORT_SV_STATUS,0,com.android.server.location.GnssLocationProvider$SvStatusInfo@5743010)发布
2019-07-18 21:12:08.025 2022-2045 / system_process E / BatteryExternalStatsWorker:没有为WiFi提供控制器能量信息