对不起,但仍然是新手。
我设法获得AsyncMap
并在我的位置显示我的标记。
现在,我查询Firebase数据库以检索数据以放置更多标记
public void addMarkers() {
if(noUpdateLocation.equals("not_allowed")){
Query latitudeToAdd = markersNotAllowedToAdd.orderByChild("location_lat").limitToFirst(10).endAt(online_user_id);
latitudeToAdd.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Iterable<DataSnapshot> latitudeIterator = dataSnapshot.getChildren();
Iterator<DataSnapshot> iterator = latitudeIterator.iterator();
while(iterator.hasNext()){
DataSnapshot foundLatitude = iterator.next();
latitudeList.add((Double) foundLatitude.child("location_lat").getValue());
Log.d(TAG,"addMarkers :" + latitudeList.toString());
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
Query longitudeToAdd = markersNotAllowedToAdd.orderByChild("location_lng").limitToFirst(10).endAt(online_user_id);
longitudeToAdd.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Iterable<DataSnapshot> longitudeIterator = dataSnapshot.getChildren();
Iterator<DataSnapshot> iterator = longitudeIterator.iterator();
while(iterator.hasNext()){
DataSnapshot foundLongitude = iterator.next();
longitudeList.add((Double) foundLongitude.child("location_lat").getValue());
Log.d(TAG,"addMarkers : " + longitudeList.toString());
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
当我尝试运行它并获得有关结果的日志时,我得到了消息
W/art: Before Android 4.1, method int android.support.v7.widget.DropDownListView.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
我在addMarkers方法内部编写的代码的最后一部分是
mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
for(int i=0; i<latitudeList.size();i++){
LatLng markersLatLng = new LatLng(latitudeList.get(i),longitudeList.get(i));
mMap.addMarker(new MarkerOptions()
.position(markersLatLng));
Log.d(TAG,"add Markers :" + markersLatLng.toString());
}
}
});
未添加或显示任何标记。 我在哪里错了?