【发布时间】:2016-10-12 06:24:53
【问题描述】:
我正在开发一个在地图上显示司机的应用程序。我为此使用了 GeoFire。在我的应用程序中,我只需要显示那些可用的驱动程序。 请查看附件图片以获得更好的信息。
如果是"is_hired":"0" && "driver_available":"true",只有这样司机才会显示在地图上,否则他们会从地图上移除。
现在,它显示所有驱动程序,因为我不知道如何使用 Firebase 上的数据过滤驱动程序。
使用 GeoFire,我需要创建一个不同的节点来更新驱动程序位置,并且它有其覆盖的方法:
@Override
public void onKeyEntered(String key, GeoLocation location) {
Log.e("KEY","KEY-->> " + key);
Log.e("Location","Location-->> " + location.latitude+","+location.longitude);
Toast.makeText(HomeActivity.this, "Marker Added", Toast.LENGTH_SHORT).show();
// Add a new marker to the map
Marker marker = this.googleMap.addMarker(new MarkerOptions().position(new LatLng(location.latitude, location.longitude)));
this.driverMarkers.put(key, marker);
}
@Override
public void onKeyExited(String key) {
// Remove any old marker
Toast.makeText(HomeActivity.this, "Marker removed", Toast.LENGTH_SHORT).show();
Marker marker = this.driverMarkers.get(key);
if (marker != null) {
marker.remove();
this.driverMarkers.remove(key);
}
}
@Override
public void onKeyMoved(String key, GeoLocation location) {
// Move the marker
Marker marker = this.driverMarkers.get(key);
if (marker != null) {
this.animateMarkerTo(marker, location.latitude, location.longitude);
}
}
我如何过滤那些未被雇用和可用的标记?
在 GeoFire 之前,我使用的是 Firebase 数据库查询。它的缺点是它要获取整个数据库驱动程序。我只需要显示附近的司机。 请帮帮我。
【问题讨论】:
标签: android firebase firebase-realtime-database geofire