0

I have about 9000 areas (i.e. 9000 lines) I have sourced in a CSV file. There are 6 location related values in each line. 1) I, therefore, have 6 arraylists holding about 9000 values each (doing this in background Async Task) . The size of each of these array lists says "6227" or something like that - so I need to troubleshoot if some values are not being added or is there an arraylist size limitation?

2) Now, I am trying to create 9000 markers with the associated values in the title and snippet section. Please point me to a good tutorial on creating a custom marker with text views. I went to some and couldn't understand anything.

3) My third question is simple: How to efficiently handle this? I am a newcomer and I hate to say that most of the tutorials I have seen on clustering or hiding are impossible to understand. Please provide an understandable description of how to handle this problem. I am begging you.

This is how I collect the data from my CSV file; This is in the background task of AsynTask; And on PostExecute, I pass these values to the method that actually plots the marker on the Google Map.

    String mLine = reader.readLine();
                    while (mLine != null) {
                        String[] coord = mLine.split(",");
                        Names.add(coord[0]);
                        city.add(coord[1]);
                        country.add(coord[2]);
                        Code.add(coord[3]);
                        arrLat=Double.parseDouble(coord[4]);
                        arrLong=Double.parseDouble(coord[5]);
                        arrLong=Double.parseDouble(coord[1]);
                        arrRadius=Double.parseDouble(coord[2]);*/
                        LatLng thisLoc = new LatLng(arrLat,arrLong);
                        coordinates.add(thisLoc);
                        mLine = reader.readLine(); 
                    }
Zac1
  • 208
  • 7
  • 34
  • check this for adding Markers in Map : http://eagle.phys.utk.edu/guidry/android/mappingDemo.html – Saif Nov 27 '15 at 10:49
  • Share the exception you are getting, Is it due to array list or map. – Shivang Nov 27 '15 at 11:40
  • No exceptions - I made sure. I just get a popup on the app that says "This app is not responding... Wait or Ok." Thanks Sarfaraj, I am checking. – Zac1 Nov 27 '15 at 18:20

1 Answers1

0

For the arraylist size limitation, it should hold up to Integer.MAX_VALUE, you may refer to this link.

I would recommend Clusterer for this particular problem. You may refer to this github sample of MarkerClusterer in which every method has a description, and should be easier to understand. Then, using Viewport Marker Manager to optimize your app's performance. This turns off the markers that are not within the bounds of the screen especially when the user is zooming.

Lastly, in customizing marker with Textview, this link might be helpful. What it does is generate a bitmap and attach it to a marker.

This is the sample code for the custom marker as taken from the link:

Bitmap.Config conf = Bitmap.Config.ARGB_8888; 
Bitmap bmp = Bitmap.createBitmap(200, 50, conf); 
Canvas canvas = new Canvas(bmp);

canvas.drawText("TEXT", 0, 50, paint); // paint defines the text     color, stroke width, size
mMap.addMarker(new MarkerOptions()
                            .position(clickedPosition)
                            //.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker2))
                            .icon(BitmapDescriptorFactory.fromBitmap(bmp))
                            .anchor(0.5f, 1)
                                );

Good luck!

Community
  • 1
  • 1
gerardnimo
  • 1,444
  • 8
  • 10