我编写了这段代码,用于使用 infoWindows 填充我的 map ,效果很好:
query.addValueEventListener(new ValueEventListener()
{
@Override
public void onDataChange(DataSnapshot dataSnapshots)
{
Marker marker;
for (DataSnapshot dataSnapshot : dataSnapshots.getChildren())
{
Location location = dataSnapshot.getValue(Location.class);
IdLocation.put(location,dataSnapshot.getKey());
marker = mgoogleMap.addMarker(new MarkerOptions()
.position(new LatLng(location.getLatitude(), location.getLongitude())) .title(getString(R.string.tipologia))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_free)));
mapLocation.put(marker,location);
}
}
@Override
public void onCancelled(DatabaseError databaseError)
{
}
});
但我不知道它是否也适用于 1M/10M 标记(我的应用程序需要具有很大的可扩展性)。在这种情况下,使用HashMap好还是我必须使用其他东西?问题也是 infoWindows 它不接受任何参数...
谢谢
最佳答案
如果您需要这种可扩展性,我建议您使用 ConcurrentHashMap,您可以关注这篇文章以获得更深入的答案:
Scalability issue with HashMap in Multithreaded Multicore system
关于java - 如果我有 1M 到 10M 的标记,使用 HashMap 是否错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40038763/