0

I've made this code for populate my map with infoWindows, that works well:

 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)
                    {

                    }
                });

but I don't know if it works well also with 1M / 10M markers (my app needs to be scalable a lot). In this case, it's good to use HashMap or I have to use other things? The problem is also infoWindows that it is not accept any params...

Thank you

Shankar
  • 8,529
  • 26
  • 90
  • 159
nani
  • 382
  • 5
  • 15
  • 1
    I think it's a good idea using a HashMap in this situation but ConcurrentHashMap would be a better idea if you're looking for scalability in the long run. – px06 Oct 14 '16 at 08:46

1 Answers1

2

I would recommend you to use ConcurrentHashMap if you need that scalability, you can take an eye to this post to more deep answer:

Scalability issue with HashMap in Multithreaded Multicore system

ConcurrentHashMap in Java?

Community
  • 1
  • 1
Jota Ge
  • 298
  • 3
  • 16