Reputation: 9398
My app has alot of overlays on the map, how do i keep the map from being so slow? Its like a 5 second delay when moving around on the map. Take a look at my code below on how i am adding people and can someone show me how to fix this so that its not so slow, I have about 80 overlays on my map and growing by the second.
ArrayList<String> lstotherslocation = MyGlobalInfomation.getOthersLocation();
List<Overlay> mapOverlays = gMapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.otherslocation);
OthersLocationOverlay otherslocation = new OthersLocationOverlay(drawable,this);
mapOverlays.clear();
for(int i = 0; i < lstotherslocation.size();i++){
number = number + 1;
OthersPoint = new GeoPoint((int) (Double.parseDouble(lstotherslocation.get(i).trim())),
(int) (Double.parseDouble(lstotherslocation.get(i + 1).trim())));
OverlayItem overlayitem = new OverlayItem(OthersPoint, "Title",
"test: " + lstotherslocation.get(i+ 2) + "\n" +
"User: " + lstotherslocation.get(i+ 3) + "\n" +
"test: " + lstotherslocation.get(i+ 4) + "\n" +
"test: " + lstotherslocation.get(i+ 5 ));
i = i + 5;
otherslocation.addOverlay(overlayitem);
mapOverlays.add(otherslocation);
Upvotes: 0
Views: 1063
Reputation: 22603
Is there a reason why mapOverlays.add(otherslocation) is inside the for loop ?
Can you try with the following code :
OthersLocationOverlay otherslocation = new OthersLocationOverlay(drawable,this);
mapOverlays.clear();
mapOverlays.add(otherslocation);
for(int i = 0; i < lstotherslocation.size();i++){
....
otherslocation.addOverlay(overlayitem);
}
I assume you want to have your 80 markers on the othersLocationOverlay ?
Upvotes: 1